diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-12-01 12:10:05 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-12-01 12:10:05 +0100 |
commit | 07802f37ddb13489cfde314716ad6181dd9b1671 (patch) | |
tree | 0a119aafdbfdbdcc5fd7cf87f513c525c27e6d2a /compiler.c | |
parent | 54ef6c09116430e5ce35777bd899f750d84e4dc1 (diff) |
syntax: disallow keywords in object property shorthand notation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'compiler.c')
-rw-r--r-- | compiler.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -1878,6 +1878,11 @@ uc_compiler_compile_object(uc_compiler_t *compiler) if (compiler->parser->prev.type == TK_LABEL && (uc_compiler_parse_check(compiler, TK_COMMA) || uc_compiler_parse_check(compiler, TK_RBRACE))) { + /* disallow keywords in this case */ + if (uc_lexer_is_keyword(compiler->parser->prev.uv)) + uc_compiler_syntax_error(compiler, compiler->parser->prev.pos, + "Invalid identifier"); + uc_compiler_emit_variable_rw(compiler, compiler->parser->prev.uv, 0); } |