Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require "global function" in global functions #543

Merged
merged 1 commit into from
Aug 5, 2022

Conversation

hishamhm
Copy link
Member

@hishamhm hishamhm commented Aug 3, 2022

This PR changes the language so that bare function name() ... end doesn't work anymore: you need to say either local function name() ... end or global function name() ... end.

Record functions still work the same way:

  • function record:field() end and function record.field() end still work.

Function values still work the same way:

  • x = function() end still works.

Bare function name() ... end still works if the file extension is .lua instead of .tl (triggering the compiler's "lax mode").

Initial feedback regarding this change was positive back in February when I brought it up in the Matrix/Gitter chat in the wake of #500, but I'd still like to get feedback before merging this significant change!

Closes #500.

@hishamhm hishamhm force-pushed the explicit-global-for-functions branch from 1074a3f to 4742eb6 Compare August 3, 2022 22:58
@github-actions
Copy link

github-actions bot commented Aug 3, 2022

Teal Playground URL: https://543--teal-playground-preview.netlify.app

@hishamhm
Copy link
Member Author

hishamhm commented Aug 3, 2022

@pdesaulniers @euclidianAce Not sure if this proposed change has any impact on tooling (any existing parsers you are using will probably continue working, but the compiler itself will produce additional syntax errors on bare function statements (technically, the error is being produced in the type-checking stage because I use the lax flag, but I think that has no difference in output)).

@hishamhm hishamhm merged commit 1a157e8 into master Aug 5, 2022
@hishamhm hishamhm deleted the explicit-global-for-functions branch August 5, 2022 13:22
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.

Global functions
1 participant