[hir] Update error message to say global

This is non ideal but at least it's a step in the right direction. 

Getting the correct error requires us to track every identifier and global, 
which seems a bit excessive for now. 

We can revisit and improve this error if this is starting to confuse folks.
This commit is contained in:
Sathya Gunasekaran
2023-11-15 17:03:55 +00:00
parent 392a4fd9da
commit 369c315ac4
11 changed files with 12 additions and 12 deletions
@@ -353,7 +353,7 @@ class InferenceState {
effect = Effect.Mutate;
} else {
CompilerError.throwInvalidReact({
reason: `This mutates a variable after it was passed to React, which means that React cannot observe changes to it`,
reason: `This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it`,
description:
place.identifier.name !== null
? `Found mutation of ${place.identifier.name}`
@@ -370,7 +370,7 @@ class InferenceState {
valueKind !== ValueKind.Context
) {
CompilerError.throwInvalidReact({
reason: `This mutates a variable after it was passed to React, which means that React cannot observe changes to it`,
reason: `This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it`,
description:
place.identifier.name !== null
? `Found mutation of ${place.identifier.name}`
@@ -15,7 +15,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
```
@@ -16,7 +16,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
```
@@ -16,7 +16,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
```
@@ -16,7 +16,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
```
@@ -18,7 +18,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
```
@@ -25,7 +25,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (13:13)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (13:13)
```
@@ -19,7 +19,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (7:7)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (7:7)
```
@@ -16,7 +16,7 @@ function Component(props) {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (5:5)
```
@@ -15,7 +15,7 @@ function Foo() {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
```
@@ -15,7 +15,7 @@ function Foo() {
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
```