X-Sharp / XSharpPublic

Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools.
Apache License 2.0
112 stars 38 forks source link

Macro compiler cannot compile strongly typed codeblocks #1591

Open cpyrgas opened 1 week ago

cpyrgas commented 1 week ago

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]
RobertvanderHulst commented 1 week ago

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.

cpyrgas commented 1 week ago

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