arnodel / golua

A Lua compiler / runtime in Go
Apache License 2.0
93 stars 10 forks source link

No backlabels in a block with return #75

Closed arnodel closed 2 years ago

arnodel commented 2 years ago

Labels at the end of a statement are called "back-labels", as a special case these can be jumped to even if there is a local variable declaration in the block between the goto statement and the label declaration. E.g.

do
    goto L
    local a = 2
    ::L::
end

There is a bug in label declaration processing which means this is allowed erroneously if the block end in a return statement, i.e.

do
    goto L
    local a = 2
    ::L::  return a
end

This PR disallows the latter.