If `r` is a record type, trying to declare `r=new r` gives a Java error
Opened this issue · 2 comments
dplassgit commented
java.lang.ClassCastException: com.plasstech.lang.d2.type.RecordSymbol cannot be cast to com.plasstech.lang.d2.type.VariableSymbol
at com.plasstech.lang.d2.codegen.ILCodeGenerator.lookupLocation(ILCodeGenerator.java:129)
at com.plasstech.lang.d2.codegen.ILCodeGenerator.access$1(ILCodeGenerator.java:123)
at com.plasstech.lang.d2.codegen.ILCodeGenerator$1.visit(ILCodeGenerator.java:271)
at com.plasstech.lang.d2.parse.node.VariableSetNode.accept(VariableSetNode.java:14)
at com.plasstech.lang.d2.codegen.ILCodeGenerator.visit(ILCodeGenerator.java:266)
at com.plasstech.lang.d2.parse.node.AssignmentNode.accept(AssignmentNode.java:29)
at com.plasstech.lang.d2.parse.node.DefaultNodeVisitor.lambda$1(DefaultNodeVisitor.java:33)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at com.plasstech.lang.d2.parse.node.DefaultNodeVisitor.visit(DefaultNodeVisitor.java:33)
at com.plasstech.lang.d2.codegen.ILCodeGenerator.visit(ILCodeGenerator.java:663)
at com.plasstech.lang.d2.parse.node.BlockNode.accept(BlockNode.java:40)
at com.plasstech.lang.d2.codegen.ILCodeGenerator.visit(ILCodeGenerator.java:732)
at com.plasstech.lang.d2.parse.node.ProcedureNode.accept(ProcedureNode.java:55)
at com.plasstech.lang.d2.parse.node.DefaultNodeVisitor.lambda$1(DefaultNodeVisitor.java:33)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at com.plasstech.lang.d2.parse.node.DefaultNodeVisitor.visit(DefaultNodeVisitor.java:33)
at com.plasstech.lang.d2.codegen.ILCodeGenerator.visit(ILCodeGenerator.java:663)
at com.plasstech.lang.d2.parse.node.BlockNode.accept(BlockNode.java:40)
at com.plasstech.lang.d2.parse.node.DefaultNodeVisitor.visit(DefaultNodeVisitor.java:9)
at com.plasstech.lang.d2.parse.node.ProgramNode.accept(ProgramNode.java:18)
at com.plasstech.lang.d2.codegen.ILCodeGenerator.generate(ILCodeGenerator.java:102)
at com.plasstech.lang.d2.codegen.ILCodeGenerator.execute(ILCodeGenerator.java:94)
at com.plasstech.lang.d2.InterpreterExecutor.execute(InterpreterExecutor.java:98)
...
dplassgit commented
Java allows this; so should d.
dplassgit commented
This is fundamentally because SymTab.java only has a single map of (String) name to Symbol, so r=new r
will not work.