Skip to content

Commit fefba6f

Browse files
Forbid implicit global functions and classes by default
Declaring functions and classes in 'this'/root considered harmful. In future we want to make function and class declarations local, but since this is a breaking change, first let's forbid implicit global functions and classes in compiler and when all projects are proved to be working, the change in language can be made. For now, if old behavior is needed, use #allow-func-decl-sugar and Old behavior: function foo() {} // this is equivalent to this["foo"] <- function foo() {} Behavior with this commit: function foo() {} // compilation error Future planned behavior: function foo() {} // equivalent to let function foo() {} // this also mean 'let function name' and 'local function name' // support may be also removed
1 parent c0a0949 commit fefba6f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

squirrel/sqstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
SQSharedState::SQSharedState(SQAllocContext allocctx) :
1616
_alloc_ctx(allocctx),
1717
_refs_table(allocctx),
18-
defaultLangFeatures(0)
18+
defaultLangFeatures(LF_NO_FUNC_DECL_SUGAR | LF_NO_CLASS_DECL_SUGAR)
1919
{
2020
_compilererrorhandler = NULL;
2121
_printfunc = NULL;

0 commit comments

Comments
 (0)