mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Support ["str"]
properties in class definitions
This commit is contained in:
parent
eeaea33c4d
commit
2cad284f10
1 changed files with 19 additions and 0 deletions
|
@ -905,6 +905,25 @@ AstStat* Parser::parseDeclaration(const Location& start)
|
||||||
{
|
{
|
||||||
props.push_back(parseDeclaredClassMethod());
|
props.push_back(parseDeclaredClassMethod());
|
||||||
}
|
}
|
||||||
|
else if (lexer.current().type == '[')
|
||||||
|
{
|
||||||
|
const Lexeme begin = lexer.current();
|
||||||
|
nextLexeme(); // [
|
||||||
|
|
||||||
|
std::optional<AstArray<char>> chars = parseCharArray();
|
||||||
|
|
||||||
|
expectMatchAndConsume(']', begin);
|
||||||
|
expectAndConsume(':', "property type annotation");
|
||||||
|
AstType* type = parseTypeAnnotation();
|
||||||
|
|
||||||
|
// TODO: since AstName conains a char*, it can't contain null
|
||||||
|
bool containsNull = chars && (strnlen(chars->data, chars->size) < chars->size);
|
||||||
|
|
||||||
|
if (chars && !containsNull)
|
||||||
|
props.push_back(AstDeclaredClassProp{AstName(chars->data), type, false});
|
||||||
|
else
|
||||||
|
report(begin.location, "String literal contains malformed escape sequence");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Name propName = parseName("property name");
|
Name propName = parseName("property name");
|
||||||
|
|
Loading…
Add table
Reference in a new issue