diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2b4448..3782886 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,7 +81,7 @@ jobs: with: path-to-lcov: ./coverage.info github-token: ${{ secrets.GITHUB_TOKEN }} - continue-on-error: true + continue-on-error: false - uses: actions/upload-artifact@v2 with: name: coverage diff --git a/Analysis/src/JsonEncoder.cpp b/Analysis/src/JsonEncoder.cpp index c7f623e..af6bffc 100644 --- a/Analysis/src/JsonEncoder.cpp +++ b/Analysis/src/JsonEncoder.cpp @@ -262,7 +262,7 @@ struct AstJsonEncoder : public AstVisitor if (comma) writeRaw(","); else - comma = false; + comma = true; write(a); } diff --git a/CLI/FileUtils.cpp b/CLI/FileUtils.cpp index b3c9557..cb993df 100644 --- a/CLI/FileUtils.cpp +++ b/CLI/FileUtils.cpp @@ -67,6 +67,10 @@ std::optional readFile(const std::string& name) if (read != size_t(length)) return std::nullopt; + // Skip first line if it's a shebang + if (length > 2 && result[0] == '#' && result[1] == '!') + result.erase(0, result.find('\n')); + return result; } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6eee61d..460e4b4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,10 +26,9 @@ If you're thinking of adding a new feature to the language, library, analysis to Luau team has internal priorities and a roadmap that may or may not align with specific features, so before starting to work on a feature please submit an issue describing the missing feature that you'd like to add. For features that result in observable change of language syntax or semantics, you'd need to [create an RFC](https://github.com/Roblox/luau/blob/master/rfcs/README.md) to make sure that the feature is needed and well designed. -Similarly to the above, please create an issue first so that we can see if we should go through with an RFC process. Finally, please note that Luau tries to carry a minimal feature set. All features must be evaluated not just for the benefits that they provide, but also for the downsides/costs in terms of language simplicity, maintainability, cross-feature interaction etc. -As such, feature requests may not be accepted, or may get to an RFC stage and get rejected there - don't expect Luau to gain a feature just because another programming language has it. +As such, feature requests may not be accepted even if a comprehensive RFC is written - don't expect Luau to gain a feature just because another programming language has it. ## Code style diff --git a/VM/src/ldo.cpp b/VM/src/ldo.cpp index 62bbdb7..43289ab 100644 --- a/VM/src/ldo.cpp +++ b/VM/src/ldo.cpp @@ -19,7 +19,7 @@ LUAU_FASTFLAGVARIABLE(LuauCcallRestoreFix, false) LUAU_FASTFLAG(LuauCoroutineClose) -LUAU_FASTFLAGVARIABLE(LuauActivateBeforeExec, false) +LUAU_FASTFLAGVARIABLE(LuauActivateBeforeExec, true) /* ** {====================================================== diff --git a/VM/src/lvmutils.cpp b/VM/src/lvmutils.cpp index 740a4cf..5d80227 100644 --- a/VM/src/lvmutils.cpp +++ b/VM/src/lvmutils.cpp @@ -53,7 +53,7 @@ const float* luaV_tovector(const TValue* obj) static void callTMres(lua_State* L, StkId res, const TValue* f, const TValue* p1, const TValue* p2) { ptrdiff_t result = savestack(L, res); - // RBOLOX: using stack room beyond top is technically safe here, but for very complicated reasons: + // using stack room beyond top is technically safe here, but for very complicated reasons: // * The stack guarantees 1 + EXTRA_STACK room beyond stack_last (see luaD_reallocstack) will be allocated // * we cannot move luaD_checkstack above because the arguments are *sometimes* pointers to the lua // stack and checkstack may invalidate those pointers @@ -74,7 +74,7 @@ static void callTMres(lua_State* L, StkId res, const TValue* f, const TValue* p1 static void callTM(lua_State* L, const TValue* f, const TValue* p1, const TValue* p2, const TValue* p3) { - // RBOLOX: using stack room beyond top is technically safe here, but for very complicated reasons: + // using stack room beyond top is technically safe here, but for very complicated reasons: // * The stack guarantees 1 + EXTRA_STACK room beyond stack_last (see luaD_reallocstack) will be allocated // * we cannot move luaD_checkstack above because the arguments are *sometimes* pointers to the lua // stack and checkstack may invalidate those pointers diff --git a/docs/_data/navigation.yml b/docs/_data/navigation.yml index 83172d8..ba337ea 100644 --- a/docs/_data/navigation.yml +++ b/docs/_data/navigation.yml @@ -29,3 +29,5 @@ pages: url: /profile - title: Library url: /library + - title: Grammar + url: /grammar diff --git a/docs/_pages/grammar.md b/docs/_pages/grammar.md new file mode 100644 index 0000000..74a5c8a --- /dev/null +++ b/docs/_pages/grammar.md @@ -0,0 +1,82 @@ +--- +permalink: /grammar +title: Grammar +toc: true +--- + +This is the complete syntax grammar for Luau in EBNF. More information about the terminal nodes String and Number +is available in the [syntax section](syntax). + +> Note: this grammar is currently missing type pack syntax for generic arguments + +```ebnf +chunk ::= {stat [`;']} [laststat [`;']] +block ::= chunk +stat ::= varlist `=' explist | + var compoundop exp | + functioncall | + do block end | + while exp do block end | + repeat block until exp | + if exp then block {elseif exp then block} [else block] end | + for binding `=' exp `,' exp [`,' exp] do block end | + for bindinglist in explist do block end | + function funcname funcbody | + local function NAME funcbody | + local bindinglist [`=' explist] | + [export] type NAME [`<' GenericTypeList `>'] `=' Type + +laststat ::= return [explist] | break | continue + +funcname ::= NAME {`.' NAME} [`:' NAME] +funcbody ::= `(' [parlist] `)' [`:' ReturnType] block end +parlist ::= bindinglist [`,' `...'] | `...' + +explist ::= {exp `,'} exp +namelist ::= NAME {`,' NAME} + +binding ::= NAME [`:' TypeAnnotation] +bindinglist ::= binding [`,' bindinglist] (* equivalent of Lua 5.1 `namelist`, except with optional type annotations *) + +var ::= NAME | prefixexp `[' exp `]' | prefixexp `.' Name +varlist ::= var {`,' var} +prefixexp ::= var | functioncall | `(' exp `)' +functioncall ::= prefixexp funcargs | prefixexp `:' NAME funcargs + +exp ::= (asexp | unop exp) { binop exp } +ifelseexp ::= if exp then exp {elseif exp then exp} else exp +asexp ::= simpleexp [`::' Type] +simpleexp ::= NUMBER | STRING | nil | true | false | `...' | tableconstructor | function body | prefixexp | ifelseexp +funcargs ::= `(' [explist] `)' | tableconstructor | STRING + +tableconstructor ::= `{' [fieldlist] `}' +fieldlist ::= field {fieldsep field} [fieldsep] +field ::= `[' exp `]' `=' exp | NAME `=' exp | exp +fieldsep ::= `,' | `;' + +compoundop :: `+=' | `-=' | `*=' | `/=' | `%=' | `^=' | `..=' +binop ::= `+' | `-' | `*' | `/' | `^' | `%' | `..' | `<' | `<=' | `>' | `>=' | `==' | `~=' | and | or +unop ::= `-' | not | `#' + +SimpleType ::= + nil | + NAME[`.' NAME] [ `<' TypeList `>' ] | + `typeof' `(' exp `)' | + TableType | + FunctionType + +Type ::= + SimpleType [`?`] | + SimpleType [`|` Type] | + SimpleType [`&` Type] + +GenericTypeList ::= NAME [`...'] {`,' NAME [`...']} +TypeList ::= Type [`,' TypeList] | ...Type +ReturnType ::= Type | `(' TypeList `)' +TableIndexer ::= `[' Type `]' `:' Type +TableProp ::= NAME `:' Type +TablePropOrIndexer ::= TableProp | TableIndexer +PropList ::= TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep] +TableType ::= `{' PropList `}' +FunctionType ::= [`<' GenericTypeList `>'] `(' [TypeList] `)' `->` ReturnType +``` diff --git a/rfcs/function-bit32-countlz-countrz.md b/rfcs/function-bit32-countlz-countrz.md index 986da70..d2439f7 100644 --- a/rfcs/function-bit32-countlz-countrz.md +++ b/rfcs/function-bit32-countlz-countrz.md @@ -4,6 +4,8 @@ Add bit32.countlz (count left zeroes) and bit32.countrz (count right zeroes) to accelerate bit scanning +**Status**: Implemented + ## Motivation All CPUs have instructions to determine the position of first/last set bit in an integer. These instructions have a variety of uses, the popular ones being: diff --git a/rfcs/syntax-default-type-alias-type-parameters.md b/rfcs/syntax-default-type-alias-type-parameters.md index 23bd71a..15d23c8 100644 --- a/rfcs/syntax-default-type-alias-type-parameters.md +++ b/rfcs/syntax-default-type-alias-type-parameters.md @@ -48,9 +48,12 @@ type A = ... -- not allowed Default type parameter values are also allowed for type packs: ```lua -type A -- ok, variadic type pack -type C -- ok, type pack with one element -type D -- ok +type A -- ok, variadic type pack +type B -- ok, type pack with no elements +type C -- ok, type pack with one element +type D -- ok, type pack with two elements +type E -- ok, variadic type pack with a different first element +type F -- ok, same type pack as T... ``` --- @@ -68,7 +71,7 @@ If all type parameters have a default type value, it is now possible to referenc type All = ... local a: All -- ok -local b: All<> -- not allowed +local b: All<> -- ok as well ``` If type is exported from a module, default type parameter values will still be available when module is imported.