Lambda expressions don’t seem to work properly with default arguments. They’re treated as if they weren’t assigned. This would be fine if it’s the intended behavior, but an error message is not provided. Assuming default arguments are intended to work, then this is a bug, rather than a missing error.
Testing was performed with mx2cc version 1.0.7.
Example:
Monkey
1
2
3
4
5
6
7
8
9
10
11
12
13
FunctionMain:Void()
Localf:=Lambda(msg:String="Hello world.")
Print(msg)
End
ForLocali:=0Until200
f()
Next
f("Done.")
Return
End
Presuming the rules for lambdas are the same as functions, this should output “Hello world.” 200 times, then output “Done.”.
MX2CC currently produces an error claiming that no arguments were given, ignoring the default assignment, for better or worse.
monkey2/tmp/untitled1.monkey2 [7] : Error : Wrong number of arguments – expecting 1 not 0
Started an issue. I presume GitHub’s the correct place to post bugs, then? I originally intended to post to GitHub, but I didn’t know if this was intended behavior or not.
I’m really glad you’re adopting GitHub as a part of bug tracking and discussion.
Just for the record, you know the creator of a repository can also open issues, right? In other words, if you end up finding a bug you want to fix later, you can add and document it.