Update hoisting error message to allow error aggregation

Interpolating values into the `reason` field of an error breaks our error 
aggregation. This PR moves the offending function name into the `description` 
field which isn't used for aggregation.
This commit is contained in:
Joe Savona
2024-01-11 15:54:55 -08:00
parent f6f042d747
commit c3a947643f
4 changed files with 5 additions and 6 deletions
@@ -646,9 +646,8 @@ function checkFunctionReferencedBeforeDeclarationAtTopLevel(
if (scope === null) {
errors.pushErrorDetail(
new CompilerErrorDetail({
reason: `Encountered ${fn.name} used before declaration which breaks Forget's gating codegen due to hoisting`,
description:
"Rewrite the reference to not use hoisting to fix this issue",
reason: `Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting`,
description: `Rewrite the reference to ${fn.name} to not rely on hoisting to fix this issue`,
loc: fn.loc ?? null,
suggestions: null,
severity: ErrorSeverity.Invariant,
@@ -12,7 +12,7 @@ component Foo(ref: React.RefSetter<Controls>) {
## Error
```
[ReactForget] Invariant: Encountered Foo_withRef used before declaration which breaks Forget's gating codegen due to hoisting. Rewrite the reference to not use hoisting to fix this issue (2:2)
[ReactForget] Invariant: Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting. Rewrite the reference to Foo_withRef to not rely on hoisting to fix this issue (2:2)
```
@@ -14,7 +14,7 @@ function Foo_withRef(props, ref) {
## Error
```
[ReactForget] Invariant: Encountered Foo_withRef used before declaration which breaks Forget's gating codegen due to hoisting. Rewrite the reference to not use hoisting to fix this issue (3:3)
[ReactForget] Invariant: Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting. Rewrite the reference to Foo_withRef to not rely on hoisting to fix this issue (3:3)
```
@@ -14,7 +14,7 @@ function Foo() {}
## Error
```
[ReactForget] Invariant: Encountered Foo used before declaration which breaks Forget's gating codegen due to hoisting. Rewrite the reference to not use hoisting to fix this issue (5:5)
[ReactForget] Invariant: Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting. Rewrite the reference to Foo to not rely on hoisting to fix this issue (5:5)
```