Skip to content

Commit d33f881

Browse files
committed
Fix usage of variables as default proc arguments
Fixes: `@var = null; proc _test(@A = null, @b = @var) {}` Resulting in: `Procedure parameters after optional parameters must be optional or varargs.`.
1 parent b0c1aa4 commit d33f881

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/main/java/com/laytonsmith/core/functions/DataHandling.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,8 +1593,15 @@ public static Procedure getProcedure(Target t, Environment env, Script parent, P
15931593
} finally {
15941594
env.getEnv(GlobalEnv.class).ClearFlag(GlobalEnv.FLAG_VAR_ARGS_ALLOWED);
15951595
}
1596+
1597+
// Get default parameter value from IVariable.
15961598
if(paramDefaultValues[i] instanceof IVariable ivar) {
15971599
paramDefaultValues[i] = originalList.get(ivar.getVariableName(), t, env).ival();
1600+
1601+
// Map undefined default value to null since the parameter is defined.
1602+
if(paramDefaultValues[i] == CNull.UNDEFINED) {
1603+
paramDefaultValues[i] = CNull.NULL;
1604+
}
15981605
}
15991606

16001607
// Mark proc as not constant if a default parameter is not a constant.

0 commit comments

Comments
 (0)