sway-core: Clarify error for self used without a self parameter#7647
sway-core: Clarify error for self used without a self parameter#7647Dnreikronos wants to merge 3 commits into
Conversation
|
Thanks for the contribution! Before we can merge this, we need @blsoaresdev-stack to sign the Fuel Labs Contributor License Agreement. |
PR SummaryLow Risk Overview Variable expression type-checking now special-cases Reviewed by Cursor Bugbot for commit 44836c2. Bugbot is set up for automated code reviews on this repo. Configure here. |
4189257 to
f1054ee
Compare
Using `self` as a value in a method without a `self` parameter resolved to the injected `Self` type parameter, producing the misleading "used as a variable, but it is actually a generic type parameter" message. Detect that case and emit SelfParameterNotAvailable, which points at the missing `self` parameter instead. Closes FuelLabs#7645
f1054ee to
92efa2e
Compare
|
cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 92efa2e. Configure here.
Split self-without-self test into separate functions The filecheck `check`/`nextln` pairs were binding to the wrong error. With both `self.x()` and bare `self` in one function, the bare `self` line showed up as trailing context inside the first error block, so the second `check: let _ = self;` matched there and its `nextln` for the error message failed (the next line was `}`, not the message). Putting each use in its own function keeps the two error context windows from overlapping, so each check/nextln pair binds to its own error. @
86d6013 to
44836c2
Compare
Closes #7645
Using
selfas a value inside a method that has noselfparameter reported "Identifier "self" was used as a variable, but it is actually a generic type parameter." That is misleading:selfis a keyword, not a user generic. It happens because bothselfandSelfget inserted into the namespace as the injectedSelftype parameter, so resolution falls through to it once no realselfparameter shadows the name.Special-case that resolution and emit a new
SelfParameterNotAvailableerror pointing at the missingselfparameter.Selfand methods that do takeselfare unaffected, since a realselfparameter resolves to a variable. Adds a should_fail test covering both the method-receiver and bare-value uses.