Skip to content

fix: allow goto to a label at the end of a block#1139

Merged
hishamhm merged 1 commit into
teal-language:mainfrom
mtdowling:allow-label-end-of-block
Jul 11, 2026
Merged

fix: allow goto to a label at the end of a block#1139
hishamhm merged 1 commit into
teal-language:mainfrom
mtdowling:allow-label-end-of-block

Conversation

@mtdowling

Copy link
Copy Markdown
Contributor

The goto validity check from #1121 rejected jumps over local declarations to a label at the end of a block, such as the common goto continue idiom. Lua permits this. A label followed only by other labels at the end of a block is outside the scope of the block's locals.

The relaxation does not apply to labels at the end of a repeat body, whose locals remain visible in the until condition, nor to labels followed by a return statement, matching PUC-Lua.

@mtdowling

Copy link
Copy Markdown
Contributor Author

CI failed due to the playground timing out. Seems to be a recurring issue based on the other open PR.

@mtdowling

Copy link
Copy Markdown
Contributor Author

I think just merging this would make installing Teal with --dev work for me. 🙏

@mbartlett21 mbartlett21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. Only comment would be on the mentioned test.

Looks like a bit of a cleaner implementation than I had done.

Comment thread spec/lang/statement/goto_spec.lua Outdated
The goto validity check from teal-language#1121 rejected jumps over local
declarations to a label at the end of a block, such as the common
`goto continue` idiom. Lua permits this. A label followed only by
other labels at the end of a block is outside the scope of the
block's locals.

The relaxation does not apply to labels at the end of a repeat body,
whose locals remain visible in the until condition, nor to labels
followed by a return statement, matching PUC-Lua.
@mtdowling
mtdowling force-pushed the allow-label-end-of-block branch from 26cc01b to 783b342 Compare July 11, 2026 01:33
@mtdowling
mtdowling requested a review from mbartlett21 July 11, 2026 01:33

@hishamhm hishamhm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@hishamhm
hishamhm merged commit e200845 into teal-language:main Jul 11, 2026
7 of 8 checks passed
@mtdowling

Copy link
Copy Markdown
Contributor Author

Thanks. I think the dev rock needs to be republished? It's still pulling down a version of Teal that keeps says module 'teal' not found

@hishamhm

hishamhm commented Jul 12, 2026 via email

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants