Skip to content

Commit 7825713

Browse files
committed
fix: isStaticが真ならショートハンド構文を無効化
1 parent 133c0df commit 7825713

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/parser/syntaxes/expressions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ function parseObject(s: ITokenStream, isStatic: boolean): Ast.Obj {
602602

603603
let v: Ast.Expression;
604604

605+
if (isStatic) s.expect(TokenKind.Colon);
605606
if (s.is(TokenKind.Colon)){
606607
s.next();
607608

test/aison.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ greet()`)).toThrow();
6262
expect(() => AiSON.parse('{key: (3 + 5)}')).toThrow();
6363
});
6464

65+
test.concurrent('not allowed: object shorthand', () => {
66+
expect(() => AiSON.parse('{key}')).toThrow();
67+
});
68+
6569
test.concurrent('not allowed: labeled expression', () => {
6670
expect(() => AiSON.parse('#label: eval { 1 }')).toThrow();
6771
});

0 commit comments

Comments
 (0)