https://github.com/shader-slang/slang
Revision d90d73a66d6d5c665736f58096071965734fd15b authored by Tim Foley on 02 May 2018, 00:26:20 UTC, committed by GitHub on 02 May 2018, 00:26:20 UTC
* 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
1 parent 809f520
History
Tip revision: d90d73a66d6d5c665736f58096071965734fd15b authored by Tim Foley on 02 May 2018, 00:26:20 UTC
Diagnose attempts to write to fields in methods (#530)
Tip revision: d90d73a
File Mode Size
build
docs
examples
external
source
tests
tools
.editorconfig -rw-r--r-- 937 bytes
.gitattributes -rw-r--r-- 95 bytes
.gitignore -rw-r--r-- 398 bytes
.gitmodules -rw-r--r-- 107 bytes
.travis.yml -rw-r--r-- 1.6 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.1 KB
LICENSE -rw-r--r-- 1.1 KB
Makefile -rw-r--r-- 6.3 KB
README.md -rw-r--r-- 4.9 KB
appveyor.yml -rw-r--r-- 3.5 KB
slang.h -rw-r--r-- 42.9 KB
slang.sln -rw-r--r-- 9.1 KB
test.bat -rw-r--r-- 1.4 KB

README.md

back to top