diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-05-01 17:26:20 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-01 17:26:20 -0700 |
| commit | d90d73a66d6d5c665736f58096071965734fd15b (patch) | |
| tree | d4c524ecc18938d3b826ac5bc2a3fde1cf31dd52 /source/slang/ir-validate.cpp | |
| parent | 809f520da01abc18abe12c6eb6742297ca0fe303 (diff) | |
Diagnose attempts to write to fields in methods (#530)
* Diagnose attempts to write to fields in methods
Work on #529
This helps to avoid the case where a Slang user writes a struct with helpful `setter` methods, and finds that it doesn't work as expected because the `this` parameter is currently handled like an `in` parameter (passed by value, but mutable in the callee).
Fixing this issue actually involved making a more broad fix to how l-value-ness is propagated. The existing checking logic was assuming that l-value-ness is just a property of a particular member declaration (e.g., a field is either mutable or not), and didn't take into account whether the "base expression" was mutable. This change fixes that oversight, which might lead to additional errors being issued if we aren't correctly making things mutable when we should.
A `ThisExpr` was already immutable by default, so that part didn't actually need to change. Just propagating its immutability through was enough.
As an additional assistance to users, I have added an extra diagnostic that triggers when a "destination of assignment is not an l-value" error occurs and the left-hand-side expression seems to be based on `this` (whether implicitly or explicitly). This will ideally help users to understand that the "setter" idiom is not yet supported.
* Fixed setRadius typo
Diffstat (limited to 'source/slang/ir-validate.cpp')
0 files changed, 0 insertions, 0 deletions
