Skip to content

Commit 5a73347

Browse files
committed
オブジェクトリテラルのキーに一部の予約語を書けない問題を修正
1 parent 24520bf commit 5a73347

2 files changed

Lines changed: 42 additions & 8 deletions

File tree

src/parser/plugins/validate-keyword.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@ function validateNode(node: Ast.Node): Ast.Node {
149149
}
150150
break;
151151
}
152-
case 'obj': {
153-
for (const name of node.value.keys()) {
154-
if (reservedWord.includes(name)) {
155-
throwReservedWordError(name, node.loc);
156-
}
157-
}
158-
break;
159-
}
160152
case 'namedTypeSource': {
161153
if (reservedWord.includes(node.name)) {
162154
throwReservedWordError(node.name, node.loc);

test/literals.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,48 @@ describe('literal', () => {
162162
['var'],
163163
['let'],
164164
['exists'],
165+
166+
// unused keywords
167+
['as'],
168+
['async'],
169+
['attr'],
170+
['attribute'],
171+
['await'],
172+
['catch'],
173+
['class'],
174+
['component'],
175+
['constructor'],
176+
['dictionary'],
177+
['enum'],
178+
['export'],
179+
['finally'],
180+
['fn'],
181+
['hash'],
182+
['in'],
183+
['interface'],
184+
['out'],
185+
['private'],
186+
['public'],
187+
['ref'],
188+
['static'],
189+
['struct'],
190+
['table'],
191+
['this'],
192+
['throw'],
193+
['trait'],
194+
['try'],
195+
['undefined'],
196+
['use'],
197+
['using'],
198+
['when'],
199+
['while'],
200+
['yield'],
201+
['import'],
202+
['is'],
203+
['meta'],
204+
['module'],
205+
['namespace'],
206+
['new']
165207
])('key "%s"', async (key) => {
166208
const res = await exe(`
167209
<: {

0 commit comments

Comments
 (0)