From da6c4612a36d8358fc735f75bbe2e7d9ff64a3c4 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Thu, 18 Apr 2024 09:21:24 -0700 Subject: [PATCH] [dx] Consistently use backticks for quoting input in error messages ghstack-source-id: 34e5507c08fb883c987c88f415158fac781a5f8e Pull Request resolved: https://github.com/facebook/react-forget/pull/2863 --- .../src/Entrypoint/Program.ts | 2 +- .../src/HIR/AssertConsistentIdentifiers.ts | 2 +- .../src/HIR/BuildHIR.ts | 10 +++---- .../src/HIR/Environment.ts | 2 +- .../babel-plugin-react-forget/src/HIR/HIR.ts | 8 +++--- .../src/HIR/HIRBuilder.ts | 2 +- .../src/HIR/PrintHIR.ts | 6 ++-- .../src/HIR/visitors.ts | 28 +++++++++---------- .../src/Inference/InferReactivePlaces.ts | 2 +- .../src/Inference/InferReferenceEffects.ts | 10 +++---- .../src/Optimization/DeadCodeElimination.ts | 5 +++- .../src/ReactiveScopes/BuildReactiveBlocks.ts | 2 +- .../ReactiveScopes/BuildReactiveFunction.ts | 10 +++---- .../ReactiveScopes/CodegenReactiveFunction.ts | 25 +++++++++-------- .../ReactiveScopes/FlattenReactiveLoops.ts | 2 +- .../InferReactiveScopeVariables.ts | 5 +++- ...rgeReactiveScopesThatInvalidateTogether.ts | 2 +- .../ReactiveScopes/PrintReactiveFunction.ts | 2 +- .../PropagateScopeDependencies.ts | 4 +-- .../ReactiveScopes/PruneNonEscapingScopes.ts | 9 ++++-- .../src/ReactiveScopes/visitors.ts | 10 +++---- .../src/SSA/LeaveSSA.ts | 8 +++--- .../src/Validation/ValidateHooksUsage.ts | 7 +++-- ...ror.default-param-accesses-local.expect.md | 2 +- ...p-with-context-variable-iterator.expect.md | 2 +- .../compiler/error.todo-kitchensink.expect.md | 4 +-- ...wer-property-load-into-temporary.expect.md | 2 +- ...ional-call-chain-in-logical-expr.expect.md | 2 +- ...-optional-call-chain-in-optional.expect.md | 2 +- ...o-optional-call-chain-in-ternary.expect.md | 2 +- compiler/packages/snap/src/runner-worker.ts | 6 ++-- 31 files changed, 100 insertions(+), 85 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts index 321db2fd10..e2f802dbeb 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts @@ -494,7 +494,7 @@ function getReactFunctionType( default: { assertExhaustive( pass.opts.compilationMode, - `Unexpected compilationMode '${pass.opts.compilationMode}'` + `Unexpected compilationMode \`${pass.opts.compilationMode}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/AssertConsistentIdentifiers.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/AssertConsistentIdentifiers.ts index 3a0eb566e7..32c9c67283 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/AssertConsistentIdentifiers.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/AssertConsistentIdentifiers.ts @@ -37,7 +37,7 @@ export function assertConsistentIdentifiers(fn: HIRFunction): void { for (const instr of block.instructions) { CompilerError.invariant(instr.lvalue.identifier.name === null, { reason: `Expected all lvalues to be temporaries`, - description: `Found named lvalue '${instr.lvalue.identifier.name}'`, + description: `Found named lvalue \`${instr.lvalue.identifier.name}\``, loc: instr.lvalue.loc, suggestions: null, }); diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts index 4addb51f87..46fbae1f39 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts @@ -102,7 +102,7 @@ export function lower( const identifier = builder.resolveIdentifier(param); if (identifier === null) { builder.errors.push({ - reason: `(BuildHIR::lower) Could not find binding for param '${param.node.name}'`, + reason: `(BuildHIR::lower) Could not find binding for param \`${param.node.name}\``, severity: ErrorSeverity.Invariant, loc: param.node.loc ?? null, suggestions: null, @@ -186,7 +186,7 @@ export function lower( builder.errors.push({ severity: ErrorSeverity.InvalidJS, reason: `Unexpected function body kind`, - description: `Expected function body to be an expression or a block statement, got '${body.type}'`, + description: `Expected function body to be an expression or a block statement, got \`${body.type}\``, loc: body.node.loc ?? null, suggestions: null, }); @@ -2005,7 +2005,7 @@ function lowerExpression( propName = namePath.node.name; if (propName.indexOf(":") !== -1) { builder.errors.push({ - reason: `(BuildHIR::lowerExpression) Unexpected colon in attribute name '${name}'`, + reason: `(BuildHIR::lowerExpression) Unexpected colon in attribute name \`${name}\``, severity: ErrorSeverity.Todo, loc: namePath.node.loc ?? null, suggestions: null, @@ -2658,7 +2658,7 @@ function lowerReorderableExpression( ): Place { if (!isReorderableExpression(builder, expr, true)) { builder.errors.push({ - reason: `(BuildHIR::node.lowerReorderableExpression) Expression type '${expr.type}' cannot be safely reordered`, + reason: `(BuildHIR::node.lowerReorderableExpression) Expression type \`${expr.type}\` cannot be safely reordered`, severity: ErrorSeverity.Todo, loc: expr.node.loc ?? null, suggestions: null, @@ -2987,7 +2987,7 @@ function lowerJsxMemberExpression( objectPlace = lowerJsxMemberExpression(builder, object); } else { CompilerError.invariant(object.isJSXIdentifier(), { - reason: `TypeScript refinement fail: expected 'JsxIdentifier', got '${object.node.type}'`, + reason: `TypeScript refinement fail: expected 'JsxIdentifier', got \`${object.node.type}\``, description: null, loc: object.node.loc ?? null, suggestions: null, diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts index 471fa5798b..a63985a664 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts @@ -518,7 +518,7 @@ export class Environment { if (isHookName(resolvedName)) { return this.#getCustomHookType(); } else { - log(() => `Undefined global '${name}'`); + log(() => `Undefined global \`${name}\``); } } return resolvedGlobal; diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts index ba0d5777fd..3ef1830af3 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts @@ -1088,7 +1088,7 @@ export function makeIdentifierName(name: string): ValidatedIdentifier { CompilerError.invariant(t.isValidIdentifier(name), { reason: `Expected a valid identifier name`, loc: GeneratedSource, - description: `'${name}' is not a valid JavaScript identifier`, + description: `\`${name}\` is not a valid JavaScript identifier`, suggestions: null, }); return { @@ -1104,7 +1104,7 @@ export function promoteTemporary(identifier: Identifier): void { CompilerError.invariant(identifier.name === null, { reason: `Expected a temporary (unnamed) identifier`, loc: GeneratedSource, - description: `Identifier already has a name, '${identifier.name}'`, + description: `Identifier already has a name, \`${identifier.name}\``, suggestions: null, }); identifier.name = { @@ -1125,7 +1125,7 @@ export function promoteTemporaryJsxTag(identifier: Identifier): void { CompilerError.invariant(identifier.name === null, { reason: `Expected a temporary (unnamed) identifier`, loc: GeneratedSource, - description: `Identifier already has a name, '${identifier.name}'`, + description: `Identifier already has a name, \`${identifier.name}\``, suggestions: null, }); identifier.name = { @@ -1246,7 +1246,7 @@ export function isMutableEffect( return false; } default: { - assertExhaustive(effect, `Unexpected effect '${effect}'`); + assertExhaustive(effect, `Unexpected effect \`${effect}\``); } } } diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/HIRBuilder.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/HIRBuilder.ts index 5a4b92da1b..99cc65c81b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/HIRBuilder.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/HIRBuilder.ts @@ -805,7 +805,7 @@ function getReversePostorderedBlocks(func: HIR): HIR["blocks"] { default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts index 6ef574f294..917386919e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts @@ -288,7 +288,7 @@ export function printTerminal(terminal: Terminal): Array | string { default: { assertExhaustive( terminal, - `Unexpected terminal kind '${terminal as any as Terminal}'` + `Unexpected terminal kind \`${terminal as any as Terminal}\`` ); } } @@ -680,7 +680,7 @@ export function printLValue(lval: LValue): string { return `HoistedConst ${lvalue}$`; } default: { - assertExhaustive(lval.kind, `Unexpected lvalue kind '${lval.kind}'`); + assertExhaustive(lval.kind, `Unexpected lvalue kind \`${lval.kind}\``); } } } @@ -733,7 +733,7 @@ export function printPattern(pattern: Pattern | Place | SpreadPattern): string { default: { assertExhaustive( pattern, - `Unexpected pattern kind '${(pattern as any).kind}'` + `Unexpected pattern kind \`${(pattern as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/visitors.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/visitors.ts index 17ac462c3d..43796ff365 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/visitors.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/visitors.ts @@ -147,7 +147,7 @@ export function* eachInstructionValueOperand( default: { assertExhaustive( attribute, - `Unexpected attribute kind '${(attribute as any).kind}'` + `Unexpected attribute kind \`${(attribute as any).kind}\`` ); } } @@ -242,7 +242,7 @@ export function* eachInstructionValueOperand( default: { assertExhaustive( instrValue, - `Unexpected instruction kind '${(instrValue as any).kind}'` + `Unexpected instruction kind \`${(instrValue as any).kind}\`` ); } } @@ -281,7 +281,7 @@ export function doesPatternContainSpreadElement(pattern: Pattern): boolean { default: { assertExhaustive( pattern, - `Unexpected pattern kind '${(pattern as any).kind}'` + `Unexpected pattern kind \`${(pattern as any).kind}\`` ); } } @@ -301,7 +301,7 @@ export function* eachPatternOperand(pattern: Pattern): Iterable { } else { assertExhaustive( item, - `Unexpected item kind '${(item as any).kind}'` + `Unexpected item kind \`${(item as any).kind}\`` ); } } @@ -316,7 +316,7 @@ export function* eachPatternOperand(pattern: Pattern): Iterable { } else { assertExhaustive( property, - `Unexpected item kind '${(property as any).kind}'` + `Unexpected item kind \`${(property as any).kind}\`` ); } } @@ -325,7 +325,7 @@ export function* eachPatternOperand(pattern: Pattern): Iterable { default: { assertExhaustive( pattern, - `Unexpected pattern kind '${(pattern as any).kind}'` + `Unexpected pattern kind \`${(pattern as any).kind}\`` ); } } @@ -458,7 +458,7 @@ export function mapInstructionValueOperands( default: { assertExhaustive( attribute, - `Unexpected attribute kind '${(attribute as any).kind}'` + `Unexpected attribute kind \`${(attribute as any).kind}\`` ); } } @@ -601,7 +601,7 @@ export function mapPatternOperands( default: { assertExhaustive( pattern, - `Unexpected pattern kind '${(pattern as any).kind}'` + `Unexpected pattern kind \`${(pattern as any).kind}\`` ); } } @@ -851,7 +851,7 @@ export function mapTerminalSuccessors( default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any as Terminal).kind}'` + `Unexpected terminal kind \`${(terminal as any as Terminal).kind}\`` ); } } @@ -891,7 +891,7 @@ export function terminalFallthrough(terminal: Terminal): BlockId | null { default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } @@ -991,7 +991,7 @@ export function mapOptionalFallthroughs( default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } @@ -1082,7 +1082,7 @@ export function* eachTerminalSuccessor(terminal: Terminal): Iterable { default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any as Terminal).kind}'` + `Unexpected terminal kind \`${(terminal as any as Terminal).kind}\`` ); } } @@ -1144,7 +1144,7 @@ export function mapTerminalOperands( default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } @@ -1201,7 +1201,7 @@ export function* eachTerminalOperand(terminal: Terminal): Iterable { default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/Inference/InferReactivePlaces.ts b/compiler/packages/babel-plugin-react-forget/src/Inference/InferReactivePlaces.ts index 97050fe55e..ad2f666ac1 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Inference/InferReactivePlaces.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Inference/InferReactivePlaces.ts @@ -257,7 +257,7 @@ export function inferReactivePlaces(fn: HIRFunction): void { default: { assertExhaustive( operand.effect, - `Unexpected effect kind '${operand.effect}'` + `Unexpected effect kind \`${operand.effect}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts b/compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts index e2c65e699d..6f058e678d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts @@ -237,7 +237,7 @@ export default function inferReferenceEffects( default: assertExhaustive( eff.kind, - `Unexpected function effect kind '${eff.kind}'` + `Unexpected function effect kind \`${eff.kind}\`` ); } }); @@ -313,7 +313,7 @@ class InferenceState { } CompilerError.invariant(mergedKind !== null, { reason: `InferReferenceEffects::kind: Expected at least one value`, - description: `No value found at '${printPlace(place)}'`, + description: `No value found at \`${printPlace(place)}\``, loc: place.loc, suggestions: null, }); @@ -493,7 +493,7 @@ class InferenceState { * * invariant( * valueKind.kind === ValueKindKind.Mutable, - * `expected valueKind to be 'Mutable' but found to be '${valueKind}'` + * `expected valueKind to be 'Mutable' but found to be \`${valueKind}\`` * ); */ effect = isObjectType(place.identifier) ? Effect.Store : Effect.Mutate; @@ -527,7 +527,7 @@ class InferenceState { default: { assertExhaustive( effectKind, - `Unexpected reference kind '${effectKind as any as string}'` + `Unexpected reference kind \`${effectKind as any as string}\`` ); } } @@ -931,7 +931,7 @@ function inferBlock( default: { assertExhaustive( property, - `Unexpected property kind '${(property as any).kind}'` + `Unexpected property kind \`${(property as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/Optimization/DeadCodeElimination.ts b/compiler/packages/babel-plugin-react-forget/src/Optimization/DeadCodeElimination.ts index 1dc72883ba..cc0e5a12ca 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Optimization/DeadCodeElimination.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Optimization/DeadCodeElimination.ts @@ -368,7 +368,10 @@ function pruneableValue(value: InstructionValue, state: State): boolean { return true; } default: { - assertExhaustive(value, `Unexepcted value kind '${(value as any).kind}'`); + assertExhaustive( + value, + `Unexepcted value kind \`${(value as any).kind}\`` + ); } } } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveBlocks.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveBlocks.ts index 31192dca0b..fe59caeb0b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveBlocks.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveBlocks.ts @@ -194,7 +194,7 @@ function visitBlock(context: Context, block: ReactiveBlock): void { default: { assertExhaustive( stmt, - `Unexpected statement kind '${(stmt as any).kind}'` + `Unexpected statement kind \`${(stmt as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveFunction.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveFunction.ts index 667398bf5b..257891e1fe 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveFunction.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveFunction.ts @@ -726,7 +726,7 @@ class Driver { default: { assertExhaustive( terminal.variant, - `Unexpected goto variant '${terminal.variant}'` + `Unexpected goto variant \`${terminal.variant}\`` ); } } @@ -991,7 +991,7 @@ class Driver { const testBlock = this.cx.ir.blocks.get(test.block)!; if (testBlock.terminal.kind !== "branch") { CompilerError.throwTodo({ - reason: `Unexpected terminal kind '${testBlock.terminal.kind}' for optional test block`, + reason: `Unexpected terminal kind \`${testBlock.terminal.kind}\` for optional test block`, description: null, loc: testBlock.terminal.loc, suggestions: null, @@ -1033,7 +1033,7 @@ class Driver { const testBlock = this.cx.ir.blocks.get(test.block)!; if (testBlock.terminal.kind !== "branch") { CompilerError.throwTodo({ - reason: `Unexpected terminal kind '${testBlock.terminal.kind}' for logical test block`, + reason: `Unexpected terminal kind \`${testBlock.terminal.kind}\` for logical test block`, description: null, loc: testBlock.terminal.loc, suggestions: null, @@ -1081,7 +1081,7 @@ class Driver { const testBlock = this.cx.ir.blocks.get(test.block)!; if (testBlock.terminal.kind !== "branch") { CompilerError.throwTodo({ - reason: `Unexpected terminal kind '${testBlock.terminal.kind}' for ternary test block`, + reason: `Unexpected terminal kind \`${testBlock.terminal.kind}\` for ternary test block`, description: null, loc: testBlock.terminal.loc, suggestions: null, @@ -1128,7 +1128,7 @@ class Driver { } default: { CompilerError.throwTodo({ - reason: `Support '${terminal.kind}' as a value block terminal (conditional, logical, optional chaining, etc)`, + reason: `Support \`${terminal.kind}\` as a value block terminal (conditional, logical, optional chaining, etc)`, description: null, loc: terminal.loc, suggestions: null, diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts index 16f47068ee..6aed512d84 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -337,7 +337,10 @@ function codegenBlockNoReset( break; } default: { - assertExhaustive(item, `Unexpected item kind '${(item as any).kind}'`); + assertExhaustive( + item, + `Unexpected item kind \`${(item as any).kind}\`` + ); } } } @@ -651,7 +654,7 @@ function codegenTerminal( case "for-of": { CompilerError.invariant(terminal.init.kind === "SequenceExpression", { reason: `Expected a sequence expression init for ForOf`, - description: `Got '${terminal.init.kind}' expression instead`, + description: `Got \`${terminal.init.kind}\` expression instead`, loc: terminal.init.loc, suggestions: null, }); @@ -806,7 +809,7 @@ function codegenTerminal( default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } @@ -937,7 +940,7 @@ function codegenInstructionNullable( }); } default: { - assertExhaustive(kind, `Unexpected instruction kind '${kind}'`); + assertExhaustive(kind, `Unexpected instruction kind \`${kind}\``); } } } else if ( @@ -977,7 +980,7 @@ function codegenForInit( loc: instr.loc, description: instr.value.lvalue.place.identifier.name != null - ? `'${instr.value.lvalue.place.identifier.name.value}' is a context variable` + ? `\`${instr.value.lvalue.place.identifier.name.value}\` is a context variable` : null, suggestions: null, }); @@ -1346,7 +1349,7 @@ function codegenInstructionValue( CompilerError.invariant(false, { reason: "Expected an optional value to resolve to a call expression or member expression", - description: `Got a '${optionalValue.type}'`, + description: `Got a \`${optionalValue.type}\``, loc: instrValue.loc, suggestions: null, }); @@ -1364,7 +1367,7 @@ function codegenInstructionValue( { reason: "[Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. " + - `Got a '${memberExpr.type}'`, + `Got a \`${memberExpr.type}\``, description: null, loc: memberExpr.loc ?? null, suggestions: null, @@ -1493,7 +1496,7 @@ function codegenInstructionValue( tag = convertMemberExpressionToJsx(tagValue); } else { CompilerError.invariant(tagValue.type === "StringLiteral", { - reason: `Expected JSX tag to be an identifier or string, got '${tagValue.type}'`, + reason: `Expected JSX tag to be an identifier or string, got \`${tagValue.type}\``, description: null, loc: tagValue.loc ?? null, suggestions: null, @@ -1829,7 +1832,7 @@ function codegenInstructionValue( default: { assertExhaustive( instrValue, - `Unexpected instruction value kind '${(instrValue as any).kind}'` + `Unexpected instruction value kind \`${(instrValue as any).kind}\`` ); } } @@ -1881,7 +1884,7 @@ function codegenJsxAttribute( default: { assertExhaustive( attribute, - `Unexpected attribute kind '${(attribute as any).kind}'` + `Unexpected attribute kind \`${(attribute as any).kind}\`` ); } } @@ -2057,7 +2060,7 @@ function codegenLValue( default: { assertExhaustive( pattern, - `Unexpected pattern kind '${(pattern as any).kind}'` + `Unexpected pattern kind \`${(pattern as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/FlattenReactiveLoops.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/FlattenReactiveLoops.ts index cb44bc9760..f544043c9c 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/FlattenReactiveLoops.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/FlattenReactiveLoops.ts @@ -69,7 +69,7 @@ class Transform extends ReactiveFunctionTransform { default: { assertExhaustive( stmt.terminal, - `Unexpected terminal kind '${(stmt.terminal as any).kind}'` + `Unexpected terminal kind \`${(stmt.terminal as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts index 5984a39b2b..6942eea99e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts @@ -217,7 +217,10 @@ function mayAllocate(env: Environment, instruction: Instruction): boolean { return true; } default: { - assertExhaustive(value, `Unexpected value kind '${(value as any).kind}'`); + assertExhaustive( + value, + `Unexpected value kind \`${(value as any).kind}\`` + ); } } } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts index 5e8477f457..46f9b80ac9 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts @@ -270,7 +270,7 @@ class Transform extends ReactiveFunctionTransform { CompilerError.invariant(inner.kind === "SequenceExpression", { reason: "Expected OptionalExpression value to be a SequenceExpression", - description: `Found a '${value.kind}'`, + description: `Found a \`${value.kind}\``, loc: value.loc, suggestions: null, }); @@ -1028,7 +1028,7 @@ class PropagationVisitor extends ReactiveFunctionVisitor { default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts index 96b0458be9..ed25ce77d0 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts @@ -276,7 +276,7 @@ function computeMemoizedIdentifiers(state: State): Set { function visit(id: IdentifierId, forceMemoize: boolean = false): boolean { const node = state.identifiers.get(id); CompilerError.invariant(node !== undefined, { - reason: `Expected a node for all identifiers, none found for '${id}'`, + reason: `Expected a node for all identifiers, none found for \`${id}\``, description: null, loc: null, suggestions: null, @@ -720,7 +720,10 @@ function computeMemoizationInputs( }); } default: { - assertExhaustive(value, `Unexpected value kind '${(value as any).kind}'`); + assertExhaustive( + value, + `Unexpected value kind \`${(value as any).kind}\`` + ); } } } @@ -757,7 +760,7 @@ function computePatternLValues(pattern: Pattern): Array { default: { assertExhaustive( pattern, - `Unexpected pattern kind '${(pattern as any).kind}'` + `Unexpected pattern kind \`${(pattern as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts index 857f2ba8dc..616f09fb4f 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts @@ -182,7 +182,7 @@ export class ReactiveFunctionVisitor { default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } @@ -216,7 +216,7 @@ export class ReactiveFunctionVisitor { default: { assertExhaustive( instr, - `Unexpected instruction kind '${(instr as any).kind}'` + `Unexpected instruction kind \`${(instr as any).kind}\`` ); } } @@ -279,7 +279,7 @@ export class ReactiveFunctionTransform< default: { assertExhaustive( instr, - `Unexpected instruction kind '${(instr as any).kind}'` + `Unexpected instruction kind \`${(instr as any).kind}\`` ); } } @@ -554,7 +554,7 @@ export class ReactiveFunctionTransform< default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } @@ -652,7 +652,7 @@ export function mapTerminalBlocks( default: { assertExhaustive( terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` + `Unexpected terminal kind \`${(terminal as any).kind}\`` ); } } diff --git a/compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts b/compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts index 86d55e40e0..c90b2931aa 100644 --- a/compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts +++ b/compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts @@ -147,7 +147,7 @@ export function leaveSSA(fn: HIRFunction): void { if (name !== null) { CompilerError.invariant(!declarations.has(name.value), { reason: `Unexpected duplicate declaration`, - description: `Found duplicate declaration for '${name.value}'`, + description: `Found duplicate declaration for \`${name.value}\``, loc: value.lvalue.place.loc, suggestions: null, }); @@ -220,7 +220,7 @@ export function leaveSSA(fn: HIRFunction): void { kind === null || kind === InstructionKind.Const, { reason: `Expected consistent kind for destructuring`, - description: `other places were '${kind}' but '${printPlace( + description: `other places were \`${kind}\` but '${printPlace( place )}' is const`, loc: place.loc, @@ -251,7 +251,7 @@ export function leaveSSA(fn: HIRFunction): void { kind === null || kind === InstructionKind.Const, { reason: `Expected consistent kind for destructuring`, - description: `Other places were '${kind}' but '${printPlace( + description: `Other places were \`${kind}\` but '${printPlace( place )}' is const`, loc: place.loc, @@ -264,7 +264,7 @@ export function leaveSSA(fn: HIRFunction): void { kind === null || kind === InstructionKind.Reassign, { reason: `Expected consistent kind for destructuring`, - description: `Other places were '${kind}' but '${printPlace( + description: `Other places were \`${kind}\` but '${printPlace( place )}' is reassigned`, loc: place.loc, diff --git a/compiler/packages/babel-plugin-react-forget/src/Validation/ValidateHooksUsage.ts b/compiler/packages/babel-plugin-react-forget/src/Validation/ValidateHooksUsage.ts index 65bb8fab86..27d4004aef 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Validation/ValidateHooksUsage.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Validation/ValidateHooksUsage.ts @@ -286,7 +286,7 @@ export function validateHooksUsage(fn: HIRFunction): void { break; } default: { - assertExhaustive(objectKind, `Unexpected kind '${objectKind}'`); + assertExhaustive(objectKind, `Unexpected kind \`${objectKind}\``); } } setKind(instr.lvalue, kind); @@ -360,7 +360,10 @@ export function validateHooksUsage(fn: HIRFunction): void { break; } default: { - assertExhaustive(objectKind, `Unexpected kind '${objectKind}'`); + assertExhaustive( + objectKind, + `Unexpected kind \`${objectKind}\`` + ); } } setKind(lvalue, kind); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.default-param-accesses-local.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.default-param-accesses-local.expect.md index cb8d37192c..dbf084466d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.default-param-accesses-local.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.default-param-accesses-local.expect.md @@ -29,7 +29,7 @@ export const FIXTURE_ENTRYPOINT = { > 4 | return x; | ^^^^^^^^^^^^^ > 5 | } - | ^^^^ Todo: (BuildHIR::node.lowerReorderableExpression) Expression type 'ArrowFunctionExpression' cannot be safely reordered (3:5) + | ^^^^ Todo: (BuildHIR::node.lowerReorderableExpression) Expression type `ArrowFunctionExpression` cannot be safely reordered (3:5) 6 | ) { 7 | return y(); 8 | } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-for-loop-with-context-variable-iterator.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-for-loop-with-context-variable-iterator.expect.md index eaa3664c29..fd03115be1 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-for-loop-with-context-variable-iterator.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-for-loop-with-context-variable-iterator.expect.md @@ -22,7 +22,7 @@ function Component() { 4 | // NOTE: `i` is a context variable because it's reassigned and also referenced 5 | // within a closure, the `onClick` handler of each item > 6 | for (let i = MIN; i <= MAX; i += INCREMENT) { - | ^^^^^^^^^^^ Todo: Support for loops where the index variable is a context variable. 'i' is a context variable (6:6) + | ^^^^^^^^^^^ Todo: Support for loops where the index variable is a context variable. `i` is a context variable (6:6) 7 | items.push( data.set(i)} />); 8 | } 9 | return items; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md index 5d3a03d90a..956f3ee1ef 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md @@ -108,9 +108,9 @@ Todo: (BuildHIR::lowerExpression) Handle UpdateExpression with MemberExpression Todo: (BuildHIR::lowerExpression) Handle UpdateExpression with MemberExpression argument (50:50) -Todo: (BuildHIR::node.lowerReorderableExpression) Expression type 'MemberExpression' cannot be safely reordered (57:57) +Todo: (BuildHIR::node.lowerReorderableExpression) Expression type `MemberExpression` cannot be safely reordered (57:57) -Todo: (BuildHIR::node.lowerReorderableExpression) Expression type 'BinaryExpression' cannot be safely reordered (53:53) +Todo: (BuildHIR::node.lowerReorderableExpression) Expression type `BinaryExpression` cannot be safely reordered (53:53) 4 | 5 | class Bar { 6 | #secretSauce = 42; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-nested-method-calls-lower-property-load-into-temporary.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-nested-method-calls-lower-property-load-into-temporary.expect.md index 69335bfecf..a14dd18d10 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-nested-method-calls-lower-property-load-into-temporary.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-nested-method-calls-lower-property-load-into-temporary.expect.md @@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = { 3 | function Component(props) { 4 | const items = makeArray(0, 1, 2, null, 4, false, 6); > 5 | const max = Math.max(...items.filter(Boolean)); - | ^^^^^^^^ Invariant: [Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. Got a 'Identifier' (5:5) + | ^^^^^^^^ Invariant: [Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. Got a `Identifier` (5:5) 6 | return max; 7 | } 8 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-logical-expr.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-logical-expr.expect.md index 6d1278288f..b8305ff080 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-logical-expr.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-logical-expr.expect.md @@ -23,7 +23,7 @@ export const FIXTURE_ENTRYPONT = { 3 | function useFoo(props: { value: { x: string; y: string } | null }) { 4 | const value = props.value; > 5 | return useNoAlias(value?.x, value?.y) ?? {}; - | ^^^^^^^^ Todo: Unexpected terminal kind 'optional' for logical test block (5:5) + | ^^^^^^^^ Todo: Unexpected terminal kind `optional` for logical test block (5:5) 6 | } 7 | 8 | export const FIXTURE_ENTRYPONT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-optional.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-optional.expect.md index d1f305fadb..4ec85cc632 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-optional.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-optional.expect.md @@ -25,7 +25,7 @@ export const FIXTURE_ENTRYPONT = { 1 | function useFoo(props: { value: { x: string; y: string } | null }) { 2 | const value = props.value; > 3 | return createArray(value?.x, value?.y)?.join(", "); - | ^^^^^^^^ Todo: Unexpected terminal kind 'optional' for optional test block (3:3) + | ^^^^^^^^ Todo: Unexpected terminal kind `optional` for optional test block (3:3) 4 | } 5 | 6 | function createArray(...args: Array): Array { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-ternary.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-ternary.expect.md index 10f9cacc47..9fa87353b2 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-ternary.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-ternary.expect.md @@ -23,7 +23,7 @@ export const FIXTURE_ENTRYPONT = { 3 | function useFoo(props: { value: { x: string; y: string } | null }) { 4 | const value = props.value; > 5 | return useNoAlias(value?.x, value?.y) ? {} : null; - | ^^^^^^^^ Todo: Unexpected terminal kind 'optional' for ternary test block (5:5) + | ^^^^^^^^ Todo: Unexpected terminal kind `optional` for ternary test block (5:5) 6 | } 7 | 8 | export const FIXTURE_ENTRYPONT = { diff --git a/compiler/packages/snap/src/runner-worker.ts b/compiler/packages/snap/src/runner-worker.ts index 348a1ab619..6540b8606b 100644 --- a/compiler/packages/snap/src/runner-worker.ts +++ b/compiler/packages/snap/src/runner-worker.ts @@ -158,13 +158,13 @@ export async function transformFixture( let unexpectedError: string | null = null; if (expectError) { if (error === null) { - unexpectedError = `Expected an error to be thrown for fixture: '${basename}', remove the 'error.' prefix if an error is not expected.`; + unexpectedError = `Expected an error to be thrown for fixture: \`${basename}\`, remove the 'error.' prefix if an error is not expected.`; } } else { if (error !== null) { - unexpectedError = `Expected fixture '${basename}' to succeed but it failed with error:\n\n${error}`; + unexpectedError = `Expected fixture \`${basename}\` to succeed but it failed with error:\n\n${error}`; } else if (compileResult == null) { - unexpectedError = `Expected output for fixture '${basename}'.`; + unexpectedError = `Expected output for fixture \`${basename}\`.`; } }