Skip to content

Commit 85dff53

Browse files
authored
fix(codemode): label supported and unsupported syntax in the hint (#48200)
1 parent 297019e commit 85dff53

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎packages/codemode/src/interpreter/model.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class InterpreterRuntimeError extends Error {
111111

112112
// Orient the agent rather than enumerate JavaScript; interpreter-support.md is the full matrix.
113113
export const supportedSyntaxMessage =
114-
"Programs run a JavaScript subset for calling tools: plain and async functions, data literals, destructuring, standard control flow, await/Promise, and common built-ins (Array, Object, Math, JSON, Date, RegExp, Map, Set, URL). Classes, this, getters/setters, tagged templates, BigInt, and custom Symbols are unavailable; use plain functions and data objects instead."
114+
"This is a restricted JavaScript-like language. Supported: plain and async functions, data literals, destructuring, standard control flow, await and Promise, and built-ins such as Array, Object, Math, JSON, Date, RegExp, Map, Set, and URL. Unsupported: classes, this, getters/setters, tagged templates, BigInt, and custom Symbols. Use plain functions and data objects instead."
115115

116116
export const unsupportedSyntax = (kind: string, node: AstNode): InterpreterRuntimeError =>
117117
new InterpreterRuntimeError(

‎packages/codemode/test/new-expression.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ describe("new on a non-constructible callee", () => {
7070
test("classes remain unsupported syntax", async () => {
7171
const failure = await error(`class A {}; return new A()`)
7272
expect(failure.kind).toBe("UnsupportedSyntax")
73-
expect(failure.message).toStartWith("Syntax 'ClassDeclaration' is not supported. Programs run a JavaScript subset")
74-
expect(failure.message).toContain("Classes, this, getters/setters, tagged templates, BigInt, and custom Symbols")
73+
expect(failure.message).toStartWith(
74+
"Syntax 'ClassDeclaration' is not supported. This is a restricted JavaScript-like language. Supported: ",
75+
)
76+
expect(failure.message).toContain(
77+
"Unsupported: classes, this, getters/setters, tagged templates, BigInt, and custom Symbols.",
78+
)
7579
})
7680
})

0 commit comments

Comments
 (0)