Conversation
Greptile SummaryThis PR removes unnecessary indirection in 17 compiler passes that previously accumulated errors in local
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 6f53c39 |
| if (this.logger != null) { | ||
| this.logger.logEvent(this.filename, { | ||
| kind: 'CompileError', | ||
| detail: error, | ||
| fnLoc: null, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Duplicate error logging with Program.ts
recordError() logs a CompileError event here with fnLoc: null. Later, when Program.ts receives the aggregated error via Err(env.aggregateErrors()), it calls logError() which logs the same error details again — this time with the actual fnLoc. This is visible in the dynamic-gating-bailout-nopanic test fixture, which now shows two log entries for the same error (one with fnLoc: null, one with the real location).
This may be intentional for early visibility during compilation, but it doubles the log output for every recorded error. Consider either: (1) removing the logging here and letting Program.ts handle all logging, or (2) removing the logging in Program.ts's logError for errors that come back via the Result path (as opposed to caught exceptions).
Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts
Line: 737-743
Comment:
**Duplicate error logging with `Program.ts`**
`recordError()` logs a `CompileError` event here with `fnLoc: null`. Later, when `Program.ts` receives the aggregated error via `Err(env.aggregateErrors())`, it calls `logError()` which logs the same error details again — this time with the actual `fnLoc`. This is visible in the `dynamic-gating-bailout-nopanic` test fixture, which now shows two log entries for the same error (one with `fnLoc: null`, one with the real location).
This may be intentional for early visibility during compilation, but it doubles the log output for every recorded error. Consider either: (1) removing the logging here and letting `Program.ts` handle all logging, or (2) removing the logging in `Program.ts`'s `logError` for errors that come back via the `Result` path (as opposed to caught exceptions).
How can I resolve this? If you propose a fix, please make it concise.| description: `Handle '${value.kind} lvalues`, | ||
| suggestions: null, | ||
| }); | ||
| fn.env.recordError( |
There was a problem hiding this comment.
Inconsistent env reference
This line uses fn.env.recordError() while the rest of the function uses the env parameter (e.g., line 110). Both refer to the same Environment instance since the compiler shares a single env across nested functions, so this isn't a bug, but it's inconsistent with the pattern in the rest of this function.
| fn.env.recordError( | |
| env.recordError( |
Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateContextVariableLValues.ts
Line: 74
Comment:
**Inconsistent env reference**
This line uses `fn.env.recordError()` while the rest of the function uses the `env` parameter (e.g., line 110). Both refer to the same `Environment` instance since the compiler shares a single env across nested functions, so this isn't a bug, but it's inconsistent with the pattern in the rest of this function.
```suggestion
env.recordError(
```
How can I resolve this? If you propose a fix, please make it concise.…env.recordError() Removes unnecessary indirection in 17 compiler passes that previously accumulated errors in a local `CompilerError` instance before flushing them to `env.recordErrors()` at the end of each pass. Errors are now emitted directly via `env.recordError()` as they're discovered. For passes with recursive error-detection patterns (ValidateNoRefAccessInRender, ValidateNoSetStateInRender), the internal accumulator is kept but flushed via individual `recordError()` calls. For InferMutationAliasingRanges, a `shouldRecordErrors` flag preserves the conditional suppression logic. For TransformFire, the throw-based error propagation is replaced with direct recording plus an early-exit check in Pipeline.ts.
|
Upstream PR was closed or merged. Code is synced via branch mirror. |
Mirror of facebook/react#35882
Original author: josephsavona
Removes unnecessary indirection in 17 compiler passes that previously
accumulated errors in a local
CompilerErrorinstance before flushingthem to
env.recordErrors()at the end of each pass. Errors are nowemitted directly via
env.recordError()as they're discovered.For passes with recursive error-detection patterns (ValidateNoRefAccessInRender,
ValidateNoSetStateInRender), the internal accumulator is kept but flushed
via individual
recordError()calls. For InferMutationAliasingRanges,a
shouldRecordErrorsflag preserves the conditional suppression logic.For TransformFire, the throw-based error propagation is replaced with
direct recording plus an early-exit check in Pipeline.ts.
Stack created with Sapling. Best reviewed with ReviewStack.