summaryrefslogtreecommitdiffhomepage
path: root/compiler.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-12-01 12:10:05 +0100
committerJo-Philipp Wich <jo@mein.io>2021-12-01 12:10:05 +0100
commit07802f37ddb13489cfde314716ad6181dd9b1671 (patch)
tree0a119aafdbfdbdcc5fd7cf87f513c525c27e6d2a /compiler.c
parent54ef6c09116430e5ce35777bd899f750d84e4dc1 (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.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler.c b/compiler.c
index 6c89eb9..e7bbd7f 100644
--- a/compiler.c
+++ b/compiler.c
@@ -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);
}