Merge branch 'master' into merge

This commit is contained in:
Arseny Kapoulkine 2021-12-10 13:19:49 -08:00
commit 891948ef30
10 changed files with 103 additions and 11 deletions

View File

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

View File

@ -262,7 +262,7 @@ struct AstJsonEncoder : public AstVisitor
if (comma)
writeRaw(",");
else
comma = false;
comma = true;
write(a);
}

View File

@ -67,6 +67,10 @@ std::optional<std::string> 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;
}

View File

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

View File

@ -19,7 +19,7 @@
LUAU_FASTFLAGVARIABLE(LuauCcallRestoreFix, false)
LUAU_FASTFLAG(LuauCoroutineClose)
LUAU_FASTFLAGVARIABLE(LuauActivateBeforeExec, false)
LUAU_FASTFLAGVARIABLE(LuauActivateBeforeExec, true)
/*
** {======================================================

View File

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

View File

@ -29,3 +29,5 @@ pages:
url: /profile
- title: Library
url: /library
- title: Grammar
url: /grammar

82
docs/_pages/grammar.md Normal file
View File

@ -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
```

View File

@ -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:

View File

@ -48,9 +48,12 @@ type A<T, U = V, V = T> = ... -- not allowed
Default type parameter values are also allowed for type packs:
```lua
type A<T, U... = ...string> -- ok, variadic type pack
type C<T, U... = string> -- ok, type pack with one element
type D<T..., U... = T...> -- ok
type A<T, U... = ...string> -- ok, variadic type pack
type B<T, U... = ()> -- ok, type pack with no elements
type C<T, U... = (string)> -- ok, type pack with one element
type D<T, U... = (string, number)> -- ok, type pack with two elements
type E<T, U... = (string, ...number)> -- ok, variadic type pack with a different first element
type F<T..., U... = T...> -- 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<T = string, U = number> = ...
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.