fixes for variable declarations

main
Sandy Brownlee 2 years ago
parent e6487369ef
commit d12fc63571
  1. 3
      Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java

@ -678,6 +678,7 @@ public final class Checker implements ActualParameterVisitor<FormalParameter, Vo
public TypeDenoter visitDotVname(DotVname ast, Void arg) { public TypeDenoter visitDotVname(DotVname ast, Void arg) {
ast.type = null; ast.type = null;
var vType = ast.V.visit(this); var vType = ast.V.visit(this);
ast.variable = ast.V.variable;
if (vType instanceof RecordTypeDenoter record) { if (vType instanceof RecordTypeDenoter record) {
ast.type = checkFieldIdentifier(record.FT, ast.I); ast.type = checkFieldIdentifier(record.FT, ast.I);
checkAndReportError(!ast.type.equals(StdEnvironment.errorType), "no field \"%\" in this record type", checkAndReportError(!ast.type.equals(StdEnvironment.errorType), "no field \"%\" in this record type",
@ -695,8 +696,10 @@ public final class Checker implements ActualParameterVisitor<FormalParameter, Vo
var binding = ast.I.visit(this); var binding = ast.I.visit(this);
if (binding instanceof ConstantDeclaration constant) { if (binding instanceof ConstantDeclaration constant) {
ast.variable = false;
return ast.type = constant.getType(); return ast.type = constant.getType();
} else if (binding instanceof VariableDeclaration variable) { } else if (binding instanceof VariableDeclaration variable) {
ast.variable = true;
return ast.type = variable.getType(); return ast.type = variable.getType();
} }