Skip to content
Permalink
Browse files
Handle void correctly in the procedure type hinting
Fixes #1191
  • Loading branch information
LadyCailin committed May 20, 2020
1 parent eeb36e7 commit dd3c66270e39b9faf17e45af8b1f5927bb8e49b0
Showing 1 changed file with 7 additions and 1 deletion.
@@ -3,6 +3,7 @@
import com.laytonsmith.PureUtilities.Common.StringUtils;
import com.laytonsmith.core.constructs.Auto;
import com.laytonsmith.core.constructs.CArray;
import com.laytonsmith.core.constructs.CBoolean;
import com.laytonsmith.core.constructs.CClassType;
import com.laytonsmith.core.constructs.CFunction;
import com.laytonsmith.core.constructs.CNull;
@@ -201,7 +202,12 @@ public Mixed execute(List<Mixed> args, Environment oldEnv, Target t) {
arguments.set(i, c, t);
if(varIndex.size() > i) {
IVariable var = varIndex.get(i);
if(c instanceof CNull || var.getDefinedType().equals(Auto.TYPE)
if(c instanceof CVoid
&& !(var.getDefinedType().equals(Auto.TYPE) || var.getDefinedType().equals(CVoid.TYPE))) {
throw new CRECastException("Procudure \"" + name + "\" expects a value of type "
+ var.getDefinedType().val() + " in argument " + (i + 1) + ", but"
+ " a void value was found instead.", c.getTarget());
} else if(!(c instanceof CVoid) && c instanceof CNull || var.getDefinedType().equals(Auto.TYPE)
|| InstanceofUtil.isInstanceof(c, var.getDefinedType(), env)) {
env.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(var.getDefinedType(),
var.getVariableName(), c, c.getTarget()));

0 comments on commit dd3c662

Please sign in to comment.