mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[cmd3] Report incorrect coroutine usage on the variable use site (#8481)
This makes error messages point directly at the variable use, instead of
on the enclosing AST node:
```
error: `outerCoroutine` may not be in scope
outerCoroutine.yield()
^
error: `outerCoroutine` may not be in scope
consume(x, outerCoroutine);
^
```
instead of
```
error: `outerCoroutine` may not be in scope
outerCoroutine.yield()
^
error: `outerCoroutine` may not be in scope
consume(x, outerCoroutine);
^
```
This commit is contained in:
@@ -55,6 +55,7 @@ class IncorrectCoroutineUseDetectorTest {
|
||||
assertEquals(
|
||||
"Coroutine `outerCoroutine` may not be in scope. Consider using `innerCoroutine`",
|
||||
error.getMessage(null));
|
||||
assertEquals(7, error.getColumnNumber()); // leading "o" in "outerCoroutine.yield()"
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,6 +91,8 @@ class IncorrectCoroutineUseDetectorTest {
|
||||
assertEquals(
|
||||
"Coroutine `outerCoroutine` may not be in scope. Consider using `innerCoroutine`",
|
||||
error.getMessage(null));
|
||||
// leading "o" in "outerCoroutine" passed to `method(outerCoroutine)`
|
||||
assertEquals(14, error.getColumnNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,6 +129,8 @@ class IncorrectCoroutineUseDetectorTest {
|
||||
assertEquals(
|
||||
"Coroutine `outerCoroutine` may not be in scope. Consider using `a` or `b`",
|
||||
error.getMessage(null));
|
||||
// leading "o" in "outerCoroutine" passed to `method(outerCoroutine)`
|
||||
assertEquals(14, error.getColumnNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,6 +171,8 @@ class IncorrectCoroutineUseDetectorTest {
|
||||
assertEquals(
|
||||
"Coroutine `outerCoroutine` may not be in scope. Consider using `a`, `b`, or `c`",
|
||||
error.getMessage(null));
|
||||
// leading "o" in "outerCoroutine" passed to `method(outerCoroutine)`
|
||||
assertEquals(14, error.getColumnNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user