XSharpPublic icon indicating copy to clipboard operation
XSharpPublic copied to clipboard

Macro compiler cannot compile strongly typed codeblocks

Open cpyrgas opened this issue 1 year ago • 2 comments

Macro compiler throws an error when compiling a string containing a strongly typed codeblock

FUNCTION Start() AS VOID
LOCAL cb AS CODEBLOCK

cb := MCompile( "{|a , b | a * b}" ) // OK
? Eval(cb ,3,4)

cb := MCompile( "{|a AS INT , b AS INT | a * b}" ) // Macrocompiler (1,5): error XM0100: Expected '|'
? Eval(cb ,3,4)
XSharp.MacroCompiler.CompilationError
Macrocompiler (1,5): error XM0100: Expected '|'

Callstack : 
XSharp.Runtime.MacroCompiler.[Method XSharp.Runtime.MacroCompiler.CompileCodeblock(macro:System.String, lAllowSingleQuotes:System.Boolean, module:System.Reflection.Module):XSharp._Codeblock]
[Method XSharp.RT.Functions.MCompile(cString:System.String, lAllowSingleQuotes:System.Boolean):XSharp._Codeblock]
[Method XSharp.RT.Functions.MCompile(cString:System.String):XSharp._Codeblock]

cpyrgas avatar Oct 07 '24 13:10 cpyrgas

I can make a quick change to allow it to parse (and ignore) the parameter type declaration. Parsing and respecting them will require much more work, and it will not make a big difference in performance.

RobertvanderHulst avatar Oct 07 '24 14:10 RobertvanderHulst

It's not of any priority, but yes, if it can be easily made to parse (and ignore) them, it would be nice

cpyrgas avatar Oct 07 '24 14:10 cpyrgas

Confirmed fixed.

cpyrgas avatar Nov 04 '24 23:11 cpyrgas