From ed697460bb81d4f40c0c4ab9c396d6f35d2f1591 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sat, 19 Oct 2024 11:03:00 -0700 Subject: Parsing dead field expressions `null` is a constant; "if(null)" will collapse. Phi w/mem keep mem even when dead. Load handles dead mem. static class Var --- .../src/test/java/com/seaofnodes/simple/Chapter10Test.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'chapter16/src/test') diff --git a/chapter16/src/test/java/com/seaofnodes/simple/Chapter10Test.java b/chapter16/src/test/java/com/seaofnodes/simple/Chapter10Test.java index a31dfab3..2a33031d 100644 --- a/chapter16/src/test/java/com/seaofnodes/simple/Chapter10Test.java +++ b/chapter16/src/test/java/com/seaofnodes/simple/Chapter10Test.java @@ -1,5 +1,6 @@ package com.seaofnodes.simple; +import com.seaofnodes.simple.evaluator.Evaluator; import com.seaofnodes.simple.node.StopNode; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -285,15 +286,13 @@ return ret; @Test public void testBug3() { Parser parser = new Parser(""" -struct s0 { - int f0; -}; -if(0>=0) return new s0; +struct s0 { int f0; }; return new s0; int v0=null.f0; """); - try { parser.parse(); fail(); } - catch( Exception e ) { assertEquals("Accessing unknown field 'f0' from 'null'", e.getMessage()); } + StopNode stop = parser.parse().iterate(); + assertEquals("return s0;", stop.toString()); + assertEquals("Obj{f0=0}", Evaluator.evaluate(stop, 0).toString()); } @Test -- cgit v1.2.3