diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-03 14:03:48 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-04 13:30:41 -0700 |
| commit | 3476d99690805b3ebe69219b326e5e1b64ebd0a4 (patch) | |
| tree | cb05c136d87603d292c44ac4e5df38d8136f1872 /src/test/java/com/seaofnodes/simple/MutabilityTest.java | |
| parent | 9a5ca20d2537179f3a8e01762c8db6b52a4db2d9 (diff) | |
| download | Simple-linear-chapter17b.tar.gz Simple-linear-chapter17b.zip | |
Chapter 17b: Syntax Sugarlinear-chapter17b
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/MutabilityTest.java')
| -rw-r--r-- | src/test/java/com/seaofnodes/simple/MutabilityTest.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/test/java/com/seaofnodes/simple/MutabilityTest.java b/src/test/java/com/seaofnodes/simple/MutabilityTest.java index 3442c54a..8f99a059 100644 --- a/src/test/java/com/seaofnodes/simple/MutabilityTest.java +++ b/src/test/java/com/seaofnodes/simple/MutabilityTest.java @@ -37,6 +37,12 @@ public class MutabilityTest { bad("struct P { !P? next; int x; }; P p=new P{next=new P;}; p.next.x=7; return 0;"); } + @Test public void testInferencePreservesAccess() { + ok("struct P { int x; }; val p=new P; p.x=7; return p.x;", "7"); + bad("struct P { int x; }; val p=new P; p=new P; return 0;"); + bad("struct P { int x; }; P p=new P; var q=p; q.x=7; return 0;"); + } + @Test public void testConstructorScope() { ok("struct P { int ~x; }; P p=new P{if(arg) x=3; else x=7;}; return p.x;", "7"); bad("int ~outer=1; struct P { int x; }; P p=new P{outer=7;}; return outer;"); |
