moonscript icon indicating copy to clipboard operation
moonscript copied to clipboard

Assignment of `if` and `switch` to a variable.

Open strait opened this issue 6 years ago • 2 comments

The current code generated for this is potentially dangerous as it injects a name into a scope where the same name may have been re-declared as local.

strait avatar Aug 22 '19 07:08 strait

The compiler is actually smart enough to not do that (you can try and stick _exp_0 = true before your assignment to switch and see what happens)

vendethiel avatar Aug 22 '19 07:08 vendethiel

It's not that, it's this.

i = if fflag
  1
else
  local i
  i = 1
  while next(i)
    i += 1
  i

It's also an issue with the do statement-as-expression being assigned.

strait avatar Aug 22 '19 18:08 strait