@samitouri / QOS-React / commits / da6c4612a3

[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

Joe Savona committed Apr 18, 2024 at 09:21 UTC da6c4612a36d8358fc735f75bbe2e7d9ff64a3c4
31 files changed +100 -85
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts
+1 -1
@@ -494,7 +494,7 @@ function getReactFunctionType(
494 default: {
495 assertExhaustive(
496 pass.opts.compilationMode,
497 - `Unexpected compilationMode '${pass.opts.compilationMode}'`
497 + `Unexpected compilationMode \`${pass.opts.compilationMode}\``
498 );
499 }
500 }
compiler/packages/babel-plugin-react-forget/src/HIR/AssertConsistentIdentifiers.ts
+1 -1
@@ -37,7 +37,7 @@ export function assertConsistentIdentifiers(fn: HIRFunction): void {
37 for (const instr of block.instructions) {
38 CompilerError.invariant(instr.lvalue.identifier.name === null, {
39 reason: `Expected all lvalues to be temporaries`,
40 - description: `Found named lvalue '${instr.lvalue.identifier.name}'`,
40 + description: `Found named lvalue \`${instr.lvalue.identifier.name}\``,
41 loc: instr.lvalue.loc,
42 suggestions: null,
43 });
compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts
+5 -5
@@ -102,7 +102,7 @@ export function lower(
102 const identifier = builder.resolveIdentifier(param);
103 if (identifier === null) {
104 builder.errors.push({
105 - reason: `(BuildHIR::lower) Could not find binding for param '${param.node.name}'`,
105 + reason: `(BuildHIR::lower) Could not find binding for param \`${param.node.name}\``,
106 severity: ErrorSeverity.Invariant,
107 loc: param.node.loc ?? null,
108 suggestions: null,
@@ -186,7 +186,7 @@ export function lower(
186 builder.errors.push({
187 severity: ErrorSeverity.InvalidJS,
188 reason: `Unexpected function body kind`,
189 - description: `Expected function body to be an expression or a block statement, got '${body.type}'`,
189 + description: `Expected function body to be an expression or a block statement, got \`${body.type}\``,
190 loc: body.node.loc ?? null,
191 suggestions: null,
192 });
@@ -2005,7 +2005,7 @@ function lowerExpression(
2005 propName = namePath.node.name;
2006 if (propName.indexOf(":") !== -1) {
2007 builder.errors.push({
2008 - reason: `(BuildHIR::lowerExpression) Unexpected colon in attribute name '${name}'`,
2008 + reason: `(BuildHIR::lowerExpression) Unexpected colon in attribute name \`${name}\``,
2009 severity: ErrorSeverity.Todo,
2010 loc: namePath.node.loc ?? null,
2011 suggestions: null,
@@ -2658,7 +2658,7 @@ function lowerReorderableExpression(
2658 ): Place {
2659 if (!isReorderableExpression(builder, expr, true)) {
2660 builder.errors.push({
2661 - reason: `(BuildHIR::node.lowerReorderableExpression) Expression type '${expr.type}' cannot be safely reordered`,
2661 + reason: `(BuildHIR::node.lowerReorderableExpression) Expression type \`${expr.type}\` cannot be safely reordered`,
2662 severity: ErrorSeverity.Todo,
2663 loc: expr.node.loc ?? null,
2664 suggestions: null,
@@ -2987,7 +2987,7 @@ function lowerJsxMemberExpression(
2987 objectPlace = lowerJsxMemberExpression(builder, object);
2988 } else {
2989 CompilerError.invariant(object.isJSXIdentifier(), {
2990 - reason: `TypeScript refinement fail: expected 'JsxIdentifier', got '${object.node.type}'`,
2990 + reason: `TypeScript refinement fail: expected 'JsxIdentifier', got \`${object.node.type}\``,
2991 description: null,
2992 loc: object.node.loc ?? null,
2993 suggestions: null,
compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts
+1 -1
@@ -518,7 +518,7 @@ export class Environment {
518 if (isHookName(resolvedName)) {
519 return this.#getCustomHookType();
520 } else {
521 - log(() => `Undefined global '${name}'`);
521 + log(() => `Undefined global \`${name}\``);
522 }
523 }
524 return resolvedGlobal;
compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts
+4 -4
@@ -1088,7 +1088,7 @@ export function makeIdentifierName(name: string): ValidatedIdentifier {
1088 CompilerError.invariant(t.isValidIdentifier(name), {
1089 reason: `Expected a valid identifier name`,
1090 loc: GeneratedSource,
1091 - description: `'${name}' is not a valid JavaScript identifier`,
1091 + description: `\`${name}\` is not a valid JavaScript identifier`,
1092 suggestions: null,
1093 });
1094 return {
@@ -1104,7 +1104,7 @@ export function promoteTemporary(identifier: Identifier): void {
1104 CompilerError.invariant(identifier.name === null, {
1105 reason: `Expected a temporary (unnamed) identifier`,
1106 loc: GeneratedSource,
1107 - description: `Identifier already has a name, '${identifier.name}'`,
1107 + description: `Identifier already has a name, \`${identifier.name}\``,
1108 suggestions: null,
1109 });
1110 identifier.name = {
@@ -1125,7 +1125,7 @@ export function promoteTemporaryJsxTag(identifier: Identifier): void {
1125 CompilerError.invariant(identifier.name === null, {
1126 reason: `Expected a temporary (unnamed) identifier`,
1127 loc: GeneratedSource,
1128 - description: `Identifier already has a name, '${identifier.name}'`,
1128 + description: `Identifier already has a name, \`${identifier.name}\``,
1129 suggestions: null,
1130 });
1131 identifier.name = {
@@ -1246,7 +1246,7 @@ export function isMutableEffect(
1246 return false;
1247 }
1248 default: {
1249 - assertExhaustive(effect, `Unexpected effect '${effect}'`);
1249 + assertExhaustive(effect, `Unexpected effect \`${effect}\``);
1250 }
1251 }
1252 }
compiler/packages/babel-plugin-react-forget/src/HIR/HIRBuilder.ts
+1 -1
@@ -805,7 +805,7 @@ function getReversePostorderedBlocks(func: HIR): HIR["blocks"] {
805 default: {
806 assertExhaustive(
807 terminal,
808 - `Unexpected terminal kind '${(terminal as any).kind}'`
808 + `Unexpected terminal kind \`${(terminal as any).kind}\``
809 );
810 }
811 }
compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts
+3 -3
@@ -288,7 +288,7 @@ export function printTerminal(terminal: Terminal): Array<string> | string {
288 default: {
289 assertExhaustive(
290 terminal,
291 - `Unexpected terminal kind '${terminal as any as Terminal}'`
291 + `Unexpected terminal kind \`${terminal as any as Terminal}\``
292 );
293 }
294 }
@@ -680,7 +680,7 @@ export function printLValue(lval: LValue): string {
680 return `HoistedConst ${lvalue}$`;
681 }
682 default: {
683 - assertExhaustive(lval.kind, `Unexpected lvalue kind '${lval.kind}'`);
683 + assertExhaustive(lval.kind, `Unexpected lvalue kind \`${lval.kind}\``);
684 }
685 }
686 }
@@ -733,7 +733,7 @@ export function printPattern(pattern: Pattern | Place | SpreadPattern): string {
733 default: {
734 assertExhaustive(
735 pattern,
736 - `Unexpected pattern kind '${(pattern as any).kind}'`
736 + `Unexpected pattern kind \`${(pattern as any).kind}\``
737 );
738 }
739 }
compiler/packages/babel-plugin-react-forget/src/HIR/visitors.ts
+14 -14
@@ -147,7 +147,7 @@ export function* eachInstructionValueOperand(
147 default: {
148 assertExhaustive(
149 attribute,
150 - `Unexpected attribute kind '${(attribute as any).kind}'`
150 + `Unexpected attribute kind \`${(attribute as any).kind}\``
151 );
152 }
153 }
@@ -242,7 +242,7 @@ export function* eachInstructionValueOperand(
242 default: {
243 assertExhaustive(
244 instrValue,
245 - `Unexpected instruction kind '${(instrValue as any).kind}'`
245 + `Unexpected instruction kind \`${(instrValue as any).kind}\``
246 );
247 }
248 }
@@ -281,7 +281,7 @@ export function doesPatternContainSpreadElement(pattern: Pattern): boolean {
281 default: {
282 assertExhaustive(
283 pattern,
284 - `Unexpected pattern kind '${(pattern as any).kind}'`
284 + `Unexpected pattern kind \`${(pattern as any).kind}\``
285 );
286 }
287 }
@@ -301,7 +301,7 @@ export function* eachPatternOperand(pattern: Pattern): Iterable<Place> {
301 } else {
302 assertExhaustive(
303 item,
304 - `Unexpected item kind '${(item as any).kind}'`
304 + `Unexpected item kind \`${(item as any).kind}\``
305 );
306 }
307 }
@@ -316,7 +316,7 @@ export function* eachPatternOperand(pattern: Pattern): Iterable<Place> {
316 } else {
317 assertExhaustive(
318 property,
319 - `Unexpected item kind '${(property as any).kind}'`
319 + `Unexpected item kind \`${(property as any).kind}\``
320 );
321 }
322 }
@@ -325,7 +325,7 @@ export function* eachPatternOperand(pattern: Pattern): Iterable<Place> {
325 default: {
326 assertExhaustive(
327 pattern,
328 - `Unexpected pattern kind '${(pattern as any).kind}'`
328 + `Unexpected pattern kind \`${(pattern as any).kind}\``
329 );
330 }
331 }
@@ -458,7 +458,7 @@ export function mapInstructionValueOperands(
458 default: {
459 assertExhaustive(
460 attribute,
461 - `Unexpected attribute kind '${(attribute as any).kind}'`
461 + `Unexpected attribute kind \`${(attribute as any).kind}\``
462 );
463 }
464 }
@@ -601,7 +601,7 @@ export function mapPatternOperands(
601 default: {
602 assertExhaustive(
603 pattern,
604 - `Unexpected pattern kind '${(pattern as any).kind}'`
604 + `Unexpected pattern kind \`${(pattern as any).kind}\``
605 );
606 }
607 }
@@ -851,7 +851,7 @@ export function mapTerminalSuccessors(
851 default: {
852 assertExhaustive(
853 terminal,
854 - `Unexpected terminal kind '${(terminal as any as Terminal).kind}'`
854 + `Unexpected terminal kind \`${(terminal as any as Terminal).kind}\``
855 );
856 }
857 }
@@ -891,7 +891,7 @@ export function terminalFallthrough(terminal: Terminal): BlockId | null {
891 default: {
892 assertExhaustive(
893 terminal,
894 - `Unexpected terminal kind '${(terminal as any).kind}'`
894 + `Unexpected terminal kind \`${(terminal as any).kind}\``
895 );
896 }
897 }
@@ -991,7 +991,7 @@ export function mapOptionalFallthroughs(
991 default: {
992 assertExhaustive(
993 terminal,
994 - `Unexpected terminal kind '${(terminal as any).kind}'`
994 + `Unexpected terminal kind \`${(terminal as any).kind}\``
995 );
996 }
997 }
@@ -1082,7 +1082,7 @@ export function* eachTerminalSuccessor(terminal: Terminal): Iterable<BlockId> {
1082 default: {
1083 assertExhaustive(
1084 terminal,
1085 - `Unexpected terminal kind '${(terminal as any as Terminal).kind}'`
1085 + `Unexpected terminal kind \`${(terminal as any as Terminal).kind}\``
1086 );
1087 }
1088 }
@@ -1144,7 +1144,7 @@ export function mapTerminalOperands(
1144 default: {
1145 assertExhaustive(
1146 terminal,
1147 - `Unexpected terminal kind '${(terminal as any).kind}'`
1147 + `Unexpected terminal kind \`${(terminal as any).kind}\``
1148 );
1149 }
1150 }
@@ -1201,7 +1201,7 @@ export function* eachTerminalOperand(terminal: Terminal): Iterable<Place> {
1201 default: {
1202 assertExhaustive(
1203 terminal,
1204 - `Unexpected terminal kind '${(terminal as any).kind}'`
1204 + `Unexpected terminal kind \`${(terminal as any).kind}\``
1205 );
1206 }
1207 }
compiler/packages/babel-plugin-react-forget/src/Inference/InferReactivePlaces.ts
+1 -1
@@ -257,7 +257,7 @@ export function inferReactivePlaces(fn: HIRFunction): void {
257 default: {
258 assertExhaustive(
259 operand.effect,
260 - `Unexpected effect kind '${operand.effect}'`
260 + `Unexpected effect kind \`${operand.effect}\``
261 );
262 }
263 }
compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts
+5 -5
@@ -237,7 +237,7 @@ export default function inferReferenceEffects(
237 default:
238 assertExhaustive(
239 eff.kind,
240 - `Unexpected function effect kind '${eff.kind}'`
240 + `Unexpected function effect kind \`${eff.kind}\``
241 );
242 }
243 });
@@ -313,7 +313,7 @@ class InferenceState {
313 }
314 CompilerError.invariant(mergedKind !== null, {
315 reason: `InferReferenceEffects::kind: Expected at least one value`,
316 - description: `No value found at '${printPlace(place)}'`,
316 + description: `No value found at \`${printPlace(place)}\``,
317 loc: place.loc,
318 suggestions: null,
319 });
@@ -493,7 +493,7 @@ class InferenceState {
493 *
494 * invariant(
495 * valueKind.kind === ValueKindKind.Mutable,
496 - * `expected valueKind to be 'Mutable' but found to be '${valueKind}'`
496 + * `expected valueKind to be 'Mutable' but found to be \`${valueKind}\``
497 * );
498 */
499 effect = isObjectType(place.identifier) ? Effect.Store : Effect.Mutate;
@@ -527,7 +527,7 @@ class InferenceState {
527 default: {
528 assertExhaustive(
529 effectKind,
530 - `Unexpected reference kind '${effectKind as any as string}'`
530 + `Unexpected reference kind \`${effectKind as any as string}\``
531 );
532 }
533 }
@@ -931,7 +931,7 @@ function inferBlock(
931 default: {
932 assertExhaustive(
933 property,
934 - `Unexpected property kind '${(property as any).kind}'`
934 + `Unexpected property kind \`${(property as any).kind}\``
935 );
936 }
937 }
compiler/packages/babel-plugin-react-forget/src/Optimization/DeadCodeElimination.ts
+4 -1
@@ -368,7 +368,10 @@ function pruneableValue(value: InstructionValue, state: State): boolean {
368 return true;
369 }
370 default: {
371 - assertExhaustive(value, `Unexepcted value kind '${(value as any).kind}'`);
371 + assertExhaustive(
372 + value,
373 + `Unexepcted value kind \`${(value as any).kind}\``
374 + );
375 }
376 }
377 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveBlocks.ts
+1 -1
@@ -194,7 +194,7 @@ function visitBlock(context: Context, block: ReactiveBlock): void {
194 default: {
195 assertExhaustive(
196 stmt,
197 - `Unexpected statement kind '${(stmt as any).kind}'`
197 + `Unexpected statement kind \`${(stmt as any).kind}\``
198 );
199 }
200 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/BuildReactiveFunction.ts
+5 -5
@@ -726,7 +726,7 @@ class Driver {
726 default: {
727 assertExhaustive(
728 terminal.variant,
729 - `Unexpected goto variant '${terminal.variant}'`
729 + `Unexpected goto variant \`${terminal.variant}\``
730 );
731 }
732 }
@@ -991,7 +991,7 @@ class Driver {
991 const testBlock = this.cx.ir.blocks.get(test.block)!;
992 if (testBlock.terminal.kind !== "branch") {
993 CompilerError.throwTodo({
994 - reason: `Unexpected terminal kind '${testBlock.terminal.kind}' for optional test block`,
994 + reason: `Unexpected terminal kind \`${testBlock.terminal.kind}\` for optional test block`,
995 description: null,
996 loc: testBlock.terminal.loc,
997 suggestions: null,
@@ -1033,7 +1033,7 @@ class Driver {
1033 const testBlock = this.cx.ir.blocks.get(test.block)!;
1034 if (testBlock.terminal.kind !== "branch") {
1035 CompilerError.throwTodo({
1036 - reason: `Unexpected terminal kind '${testBlock.terminal.kind}' for logical test block`,
1036 + reason: `Unexpected terminal kind \`${testBlock.terminal.kind}\` for logical test block`,
1037 description: null,
1038 loc: testBlock.terminal.loc,
1039 suggestions: null,
@@ -1081,7 +1081,7 @@ class Driver {
1081 const testBlock = this.cx.ir.blocks.get(test.block)!;
1082 if (testBlock.terminal.kind !== "branch") {
1083 CompilerError.throwTodo({
1084 - reason: `Unexpected terminal kind '${testBlock.terminal.kind}' for ternary test block`,
1084 + reason: `Unexpected terminal kind \`${testBlock.terminal.kind}\` for ternary test block`,
1085 description: null,
1086 loc: testBlock.terminal.loc,
1087 suggestions: null,
@@ -1128,7 +1128,7 @@ class Driver {
1128 }
1129 default: {
1130 CompilerError.throwTodo({
1131 - reason: `Support '${terminal.kind}' as a value block terminal (conditional, logical, optional chaining, etc)`,
1131 + reason: `Support \`${terminal.kind}\` as a value block terminal (conditional, logical, optional chaining, etc)`,
1132 description: null,
1133 loc: terminal.loc,
1134 suggestions: null,
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+14 -11
@@ -337,7 +337,10 @@ function codegenBlockNoReset(
337 break;
338 }
339 default: {
340 - assertExhaustive(item, `Unexpected item kind '${(item as any).kind}'`);
340 + assertExhaustive(
341 + item,
342 + `Unexpected item kind \`${(item as any).kind}\``
343 + );
344 }
345 }
346 }
@@ -651,7 +654,7 @@ function codegenTerminal(
654 case "for-of": {
655 CompilerError.invariant(terminal.init.kind === "SequenceExpression", {
656 reason: `Expected a sequence expression init for ForOf`,
654 - description: `Got '${terminal.init.kind}' expression instead`,
657 + description: `Got \`${terminal.init.kind}\` expression instead`,
658 loc: terminal.init.loc,
659 suggestions: null,
660 });
@@ -806,7 +809,7 @@ function codegenTerminal(
809 default: {
810 assertExhaustive(
811 terminal,
809 - `Unexpected terminal kind '${(terminal as any).kind}'`
812 + `Unexpected terminal kind \`${(terminal as any).kind}\``
813 );
814 }
815 }
@@ -937,7 +940,7 @@ function codegenInstructionNullable(
940 });
941 }
942 default: {
940 - assertExhaustive(kind, `Unexpected instruction kind '${kind}'`);
943 + assertExhaustive(kind, `Unexpected instruction kind \`${kind}\``);
944 }
945 }
946 } else if (
@@ -977,7 +980,7 @@ function codegenForInit(
980 loc: instr.loc,
981 description:
982 instr.value.lvalue.place.identifier.name != null
980 - ? `'${instr.value.lvalue.place.identifier.name.value}' is a context variable`
983 + ? `\`${instr.value.lvalue.place.identifier.name.value}\` is a context variable`
984 : null,
985 suggestions: null,
986 });
@@ -1346,7 +1349,7 @@ function codegenInstructionValue(
1349 CompilerError.invariant(false, {
1350 reason:
1351 "Expected an optional value to resolve to a call expression or member expression",
1349 - description: `Got a '${optionalValue.type}'`,
1352 + description: `Got a \`${optionalValue.type}\``,
1353 loc: instrValue.loc,
1354 suggestions: null,
1355 });
@@ -1364,7 +1367,7 @@ function codegenInstructionValue(
1367 {
1368 reason:
1369 "[Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. " +
1367 - `Got a '${memberExpr.type}'`,
1370 + `Got a \`${memberExpr.type}\``,
1371 description: null,
1372 loc: memberExpr.loc ?? null,
1373 suggestions: null,
@@ -1493,7 +1496,7 @@ function codegenInstructionValue(
1496 tag = convertMemberExpressionToJsx(tagValue);
1497 } else {
1498 CompilerError.invariant(tagValue.type === "StringLiteral", {
1496 - reason: `Expected JSX tag to be an identifier or string, got '${tagValue.type}'`,
1499 + reason: `Expected JSX tag to be an identifier or string, got \`${tagValue.type}\``,
1500 description: null,
1501 loc: tagValue.loc ?? null,
1502 suggestions: null,
@@ -1829,7 +1832,7 @@ function codegenInstructionValue(
1832 default: {
1833 assertExhaustive(
1834 instrValue,
1832 - `Unexpected instruction value kind '${(instrValue as any).kind}'`
1835 + `Unexpected instruction value kind \`${(instrValue as any).kind}\``
1836 );
1837 }
1838 }
@@ -1881,7 +1884,7 @@ function codegenJsxAttribute(
1884 default: {
1885 assertExhaustive(
1886 attribute,
1884 - `Unexpected attribute kind '${(attribute as any).kind}'`
1887 + `Unexpected attribute kind \`${(attribute as any).kind}\``
1888 );
1889 }
1890 }
@@ -2057,7 +2060,7 @@ function codegenLValue(
2060 default: {
2061 assertExhaustive(
2062 pattern,
2060 - `Unexpected pattern kind '${(pattern as any).kind}'`
2063 + `Unexpected pattern kind \`${(pattern as any).kind}\``
2064 );
2065 }
2066 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/FlattenReactiveLoops.ts
+1 -1
@@ -69,7 +69,7 @@ class Transform extends ReactiveFunctionTransform<boolean> {
69 default: {
70 assertExhaustive(
71 stmt.terminal,
72 - `Unexpected terminal kind '${(stmt.terminal as any).kind}'`
72 + `Unexpected terminal kind \`${(stmt.terminal as any).kind}\``
73 );
74 }
75 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts
+4 -1
@@ -217,7 +217,10 @@ function mayAllocate(env: Environment, instruction: Instruction): boolean {
217 return true;
218 }
219 default: {
220 - assertExhaustive(value, `Unexpected value kind '${(value as any).kind}'`);
220 + assertExhaustive(
221 + value,
222 + `Unexpected value kind \`${(value as any).kind}\``
223 + );
224 }
225 }
226 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts
+1 -1
@@ -270,7 +270,7 @@ class Transform extends ReactiveFunctionTransform<ReactiveScopeDependencies | nu
270 default: {
271 assertExhaustive(
272 instr,
273 - `Unexpected instruction kind '${(instr as any).kind}'`
273 + `Unexpected instruction kind \`${(instr as any).kind}\``
274 );
275 }
276 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PrintReactiveFunction.ts
+1 -1
@@ -143,7 +143,7 @@ function writeReactiveInstruction(
143 default: {
144 assertExhaustive(
145 instr,
146 - `Unexpected terminal kind '${(instr as any).kind}'`
146 + `Unexpected terminal kind \`${(instr as any).kind}\``
147 );
148 }
149 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateScopeDependencies.ts
+2 -2
@@ -718,7 +718,7 @@ class PropagationVisitor extends ReactiveFunctionVisitor<Context> {
718 CompilerError.invariant(inner.kind === "SequenceExpression", {
719 reason:
720 "Expected OptionalExpression value to be a SequenceExpression",
721 - description: `Found a '${value.kind}'`,
721 + description: `Found a \`${value.kind}\``,
722 loc: value.loc,
723 suggestions: null,
724 });
@@ -1028,7 +1028,7 @@ class PropagationVisitor extends ReactiveFunctionVisitor<Context> {
1028 default: {
1029 assertExhaustive(
1030 terminal,
1031 - `Unexpected terminal kind '${(terminal as any).kind}'`
1031 + `Unexpected terminal kind \`${(terminal as any).kind}\``
1032 );
1033 }
1034 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts
+6 -3
@@ -276,7 +276,7 @@ function computeMemoizedIdentifiers(state: State): Set<IdentifierId> {
276 function visit(id: IdentifierId, forceMemoize: boolean = false): boolean {
277 const node = state.identifiers.get(id);
278 CompilerError.invariant(node !== undefined, {
279 - reason: `Expected a node for all identifiers, none found for '${id}'`,
279 + reason: `Expected a node for all identifiers, none found for \`${id}\``,
280 description: null,
281 loc: null,
282 suggestions: null,
@@ -720,7 +720,10 @@ function computeMemoizationInputs(
720 });
721 }
722 default: {
723 - assertExhaustive(value, `Unexpected value kind '${(value as any).kind}'`);
723 + assertExhaustive(
724 + value,
725 + `Unexpected value kind \`${(value as any).kind}\``
726 + );
727 }
728 }
729 }
@@ -757,7 +760,7 @@ function computePatternLValues(pattern: Pattern): Array<LValueMemoization> {
760 default: {
761 assertExhaustive(
762 pattern,
760 - `Unexpected pattern kind '${(pattern as any).kind}'`
763 + `Unexpected pattern kind \`${(pattern as any).kind}\``
764 );
765 }
766 }
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts
+5 -5
@@ -182,7 +182,7 @@ export class ReactiveFunctionVisitor<TState = void> {
182 default: {
183 assertExhaustive(
184 terminal,
185 - `Unexpected terminal kind '${(terminal as any).kind}'`
185 + `Unexpected terminal kind \`${(terminal as any).kind}\``
186 );
187 }
188 }
@@ -216,7 +216,7 @@ export class ReactiveFunctionVisitor<TState = void> {
216 default: {
217 assertExhaustive(
218 instr,
219 - `Unexpected instruction kind '${(instr as any).kind}'`
219 + `Unexpected instruction kind \`${(instr as any).kind}\``
220 );
221 }
222 }
@@ -279,7 +279,7 @@ export class ReactiveFunctionTransform<
279 default: {
280 assertExhaustive(
281 instr,
282 - `Unexpected instruction kind '${(instr as any).kind}'`
282 + `Unexpected instruction kind \`${(instr as any).kind}\``
283 );
284 }
285 }
@@ -554,7 +554,7 @@ export class ReactiveFunctionTransform<
554 default: {
555 assertExhaustive(
556 terminal,
557 - `Unexpected terminal kind '${(terminal as any).kind}'`
557 + `Unexpected terminal kind \`${(terminal as any).kind}\``
558 );
559 }
560 }
@@ -652,7 +652,7 @@ export function mapTerminalBlocks(
652 default: {
653 assertExhaustive(
654 terminal,
655 - `Unexpected terminal kind '${(terminal as any).kind}'`
655 + `Unexpected terminal kind \`${(terminal as any).kind}\``
656 );
657 }
658 }
compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts
+4 -4
@@ -147,7 +147,7 @@ export function leaveSSA(fn: HIRFunction): void {
147 if (name !== null) {
148 CompilerError.invariant(!declarations.has(name.value), {
149 reason: `Unexpected duplicate declaration`,
150 - description: `Found duplicate declaration for '${name.value}'`,
150 + description: `Found duplicate declaration for \`${name.value}\``,
151 loc: value.lvalue.place.loc,
152 suggestions: null,
153 });
@@ -220,7 +220,7 @@ export function leaveSSA(fn: HIRFunction): void {
220 kind === null || kind === InstructionKind.Const,
221 {
222 reason: `Expected consistent kind for destructuring`,
223 - description: `other places were '${kind}' but '${printPlace(
223 + description: `other places were \`${kind}\` but '${printPlace(
224 place
225 )}' is const`,
226 loc: place.loc,
@@ -251,7 +251,7 @@ export function leaveSSA(fn: HIRFunction): void {
251 kind === null || kind === InstructionKind.Const,
252 {
253 reason: `Expected consistent kind for destructuring`,
254 - description: `Other places were '${kind}' but '${printPlace(
254 + description: `Other places were \`${kind}\` but '${printPlace(
255 place
256 )}' is const`,
257 loc: place.loc,
@@ -264,7 +264,7 @@ export function leaveSSA(fn: HIRFunction): void {
264 kind === null || kind === InstructionKind.Reassign,
265 {
266 reason: `Expected consistent kind for destructuring`,
267 - description: `Other places were '${kind}' but '${printPlace(
267 + description: `Other places were \`${kind}\` but '${printPlace(
268 place
269 )}' is reassigned`,
270 loc: place.loc,
compiler/packages/babel-plugin-react-forget/src/Validation/ValidateHooksUsage.ts
+5 -2
@@ -286,7 +286,7 @@ export function validateHooksUsage(fn: HIRFunction): void {
286 break;
287 }
288 default: {
289 - assertExhaustive(objectKind, `Unexpected kind '${objectKind}'`);
289 + assertExhaustive(objectKind, `Unexpected kind \`${objectKind}\``);
290 }
291 }
292 setKind(instr.lvalue, kind);
@@ -360,7 +360,10 @@ export function validateHooksUsage(fn: HIRFunction): void {
360 break;
361 }
362 default: {
363 - assertExhaustive(objectKind, `Unexpected kind '${objectKind}'`);
363 + assertExhaustive(
364 + objectKind,
365 + `Unexpected kind \`${objectKind}\``
366 + );
367 }
368 }
369 setKind(lvalue, kind);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.default-param-accesses-local.expect.md
+1 -1
@@ -29,7 +29,7 @@ export const FIXTURE_ENTRYPOINT = {
29 > 4 | return x;
30 | ^^^^^^^^^^^^^
31 > 5 | }
32 - | ^^^^ Todo: (BuildHIR::node.lowerReorderableExpression) Expression type 'ArrowFunctionExpression' cannot be safely reordered (3:5)
32 + | ^^^^ Todo: (BuildHIR::node.lowerReorderableExpression) Expression type `ArrowFunctionExpression` cannot be safely reordered (3:5)
33 6 | ) {
34 7 | return y();
35 8 | }
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-for-loop-with-context-variable-iterator.expect.md
+1 -1
@@ -22,7 +22,7 @@ function Component() {
22 4 | // NOTE: `i` is a context variable because it's reassigned and also referenced
23 5 | // within a closure, the `onClick` handler of each item
24 > 6 | for (let i = MIN; i <= MAX; i += INCREMENT) {
25 - | ^^^^^^^^^^^ Todo: Support for loops where the index variable is a context variable. 'i' is a context variable (6:6)
25 + | ^^^^^^^^^^^ Todo: Support for loops where the index variable is a context variable. `i` is a context variable (6:6)
26 7 | items.push(<Stringify key={i} onClick={() => data.set(i)} />);
27 8 | }
28 9 | return items;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md
+2 -2
@@ -108,9 +108,9 @@ Todo: (BuildHIR::lowerExpression) Handle UpdateExpression with MemberExpression
108
109 Todo: (BuildHIR::lowerExpression) Handle UpdateExpression with MemberExpression argument (50:50)
110
111 -Todo: (BuildHIR::node.lowerReorderableExpression) Expression type 'MemberExpression' cannot be safely reordered (57:57)
111 +Todo: (BuildHIR::node.lowerReorderableExpression) Expression type `MemberExpression` cannot be safely reordered (57:57)
112
113 -Todo: (BuildHIR::node.lowerReorderableExpression) Expression type 'BinaryExpression' cannot be safely reordered (53:53)
113 +Todo: (BuildHIR::node.lowerReorderableExpression) Expression type `BinaryExpression` cannot be safely reordered (53:53)
114 4 |
115 5 | class Bar {
116 6 | #secretSauce = 42;
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-nested-method-calls-lower-property-load-into-temporary.expect.md
+1 -1
@@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = {
24 3 | function Component(props) {
25 4 | const items = makeArray(0, 1, 2, null, 4, false, 6);
26 > 5 | const max = Math.max(...items.filter(Boolean));
27 - | ^^^^^^^^ Invariant: [Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. Got a 'Identifier' (5:5)
27 + | ^^^^^^^^ Invariant: [Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. Got a `Identifier` (5:5)
28 6 | return max;
29 7 | }
30 8 |
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-logical-expr.expect.md
+1 -1
@@ -23,7 +23,7 @@ export const FIXTURE_ENTRYPONT = {
23 3 | function useFoo(props: { value: { x: string; y: string } | null }) {
24 4 | const value = props.value;
25 > 5 | return useNoAlias(value?.x, value?.y) ?? {};
26 - | ^^^^^^^^ Todo: Unexpected terminal kind 'optional' for logical test block (5:5)
26 + | ^^^^^^^^ Todo: Unexpected terminal kind `optional` for logical test block (5:5)
27 6 | }
28 7 |
29 8 | export const FIXTURE_ENTRYPONT = {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-optional.expect.md
+1 -1
@@ -25,7 +25,7 @@ export const FIXTURE_ENTRYPONT = {
25 1 | function useFoo(props: { value: { x: string; y: string } | null }) {
26 2 | const value = props.value;
27 > 3 | return createArray(value?.x, value?.y)?.join(", ");
28 - | ^^^^^^^^ Todo: Unexpected terminal kind 'optional' for optional test block (3:3)
28 + | ^^^^^^^^ Todo: Unexpected terminal kind `optional` for optional test block (3:3)
29 4 | }
30 5 |
31 6 | function createArray<T>(...args: Array<T>): Array<T> {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-optional-call-chain-in-ternary.expect.md
+1 -1
@@ -23,7 +23,7 @@ export const FIXTURE_ENTRYPONT = {
23 3 | function useFoo(props: { value: { x: string; y: string } | null }) {
24 4 | const value = props.value;
25 > 5 | return useNoAlias(value?.x, value?.y) ? {} : null;
26 - | ^^^^^^^^ Todo: Unexpected terminal kind 'optional' for ternary test block (5:5)
26 + | ^^^^^^^^ Todo: Unexpected terminal kind `optional` for ternary test block (5:5)
27 6 | }
28 7 |
29 8 | export const FIXTURE_ENTRYPONT = {
compiler/packages/snap/src/runner-worker.ts
+3 -3
@@ -158,13 +158,13 @@ export async function transformFixture(
158 let unexpectedError: string | null = null;
159 if (expectError) {
160 if (error === null) {
161 - unexpectedError = `Expected an error to be thrown for fixture: '${basename}', remove the 'error.' prefix if an error is not expected.`;
161 + unexpectedError = `Expected an error to be thrown for fixture: \`${basename}\`, remove the 'error.' prefix if an error is not expected.`;
162 }
163 } else {
164 if (error !== null) {
165 - unexpectedError = `Expected fixture '${basename}' to succeed but it failed with error:\n\n${error}`;
165 + unexpectedError = `Expected fixture \`${basename}\` to succeed but it failed with error:\n\n${error}`;
166 } else if (compileResult == null) {
167 - unexpectedError = `Expected output for fixture '${basename}'.`;
167 + unexpectedError = `Expected output for fixture \`${basename}\`.`;
168 }
169 }
170