WrappedMacroResultException when a macro is used in the arguments to TABLE inside a routine

Description

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Zilf.Interpreter.Values.WrappedMacroResultException: Macro result was not unwrapped before usage

Stack Trace: 
ZilMacroResult.GetTypeAtom(Context ctx) line 88
ZilObject.Eval(Context ctx, LocalEnvironment environment) line 233
ZilObject.ExpandOrEvalWithSplice(Context ctx, ZilObject obj, LocalEnvironment environment) line 352
<>c__DisplayClass30_0.<EvalSequence>b__0(ZilObject zo) line 374
SelectManySingleSelectorIterator`2.MoveNext()
ZilSubr.Apply(Context ctx, ZilObject[] args) line 64
ZilForm.EvalImpl(Context ctx, LocalEnvironment environment, ZilAtom originalType) line 143
ZilObject.Eval(Context ctx, LocalEnvironment environment) line 243
ZBuiltins.TableOp(ValueCall c, ZilObject[] args) line 2083
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
MethodBase.Invoke(Object obj, Object[] parameters)
ZBuiltins.CompileBuiltinCall[TCall](String name, Compilation cc, IRoutineBuilder rb, ZilListoidBase form, TCall call) line 325
ZBuiltins.CompileValueCall(String name, Compilation cc, IRoutineBuilder rb, ZilForm form, IVariable resultStorage) line 338
Compilation.CompileForm(IRoutineBuilder rb, ZilForm form, Boolean wantResult, IVariable resultStorage) line 83
Compilation.CompileAsOperand(IRoutineBuilder rb, ZilObject expr, ISourceLine src, IVariable suggestion) line 214
ZBuiltins.SetValueOp(ValueCall c, IVariable dest, ZilObject value) line 1188
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

By the time ZBuiltins.TableOp calls c.form.Eval(), c.form contains a ZilMacroResult obtained by expanding the macro, but the value returned by the macro hasn’t been unwrapped.

Activity

Show:

Tara J. McGrew March 1, 2024 at 11:37 AM

Tara McGrew mentioned this issue in a merge request of zilf / zilf on branch topic/default/zilf-252:

Fix unhandled exception when using a macro in a call to TABLE builtins

Tara J. McGrew March 1, 2024 at 1:22 AM

Tara McGrew mentioned this issue in a commit of zilf / zilf on branch topic/default/zilf-252:

Fixed bug where an unhandled exception would be thrown if the arguments to

Fixed

Details

Assignee

Reporter

Components

Priority

Fix versions

Affects versions

Created February 18, 2024 at 11:10 PM
Updated April 7, 2024 at 10:53 AM
Resolved April 7, 2024 at 10:46 AM