teal-language / tl

The compiler for Teal, a typed dialect of Lua
MIT License
2.1k stars 108 forks source link

Require "global function" in global functions #543

Closed hishamhm closed 2 years ago

hishamhm commented 2 years ago

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 values still work the same way:

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.

github-actions[bot] commented 2 years ago

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

hishamhm commented 2 years ago

@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)).