From 4658265095b85e44d386dd14124519f46bd3779a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Sun, 3 Sep 2017 11:12:15 +0300 Subject: [PATCH] (refs #7460) Prevent NPE if variable type is null. This may happen, if the variable is defined in a pattern and the pattern type checking is not finished because of a type error. Change-Id: I91aa4c7938769f84388fbc18f089b662e3ddcb9d --- .../elaboration/expressions/EVariable.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java index 7fe0e0a92..155aa7578 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java @@ -132,8 +132,13 @@ public class EVariable extends Expression { variable.setType(Types.metaVar(Kinds.STAR)); return this; } - else + else { + if(variable.getType() == null) { + context.getErrorLog().log(location, "Type of the variable is not defined."); + variable.setType(Types.metaVar(Kinds.STAR)); + } return applyPUnit(context); + } } @Override @@ -142,8 +147,13 @@ public class EVariable extends Expression { variable.setType(requiredType); return this; } - else + else { + if(variable.getType() == null) { + context.getErrorLog().log(location, "Type of the variable is not defined."); + variable.setType(Types.metaVar(Kinds.STAR)); + } return context.subsume(this, requiredType); + } } @Override -- 2.47.1