lang: ast, parser: Allow calling anonymous functions
I forgot to plumb this in through the parser. Pretty easy to add, hopefully I didn't forget any weird corner scope cases here.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
-- main.mcl --
|
||||
$s = func() {
|
||||
"hello"
|
||||
}() # inline lambda call
|
||||
|
||||
test [$s,] {}
|
||||
-- OUTPUT --
|
||||
Vertex: test[hello]
|
||||
@@ -0,0 +1,8 @@
|
||||
-- main.mcl --
|
||||
$s = func($x) {
|
||||
"hello" + $x
|
||||
}("world") # inline lambda call
|
||||
|
||||
test [$s,] {}
|
||||
-- OUTPUT --
|
||||
Vertex: test[helloworld]
|
||||
10
lang/interpret_test/TestAstFunc2/call-inline-lambda3.txtar
Normal file
10
lang/interpret_test/TestAstFunc2/call-inline-lambda3.txtar
Normal file
@@ -0,0 +1,10 @@
|
||||
-- main.mcl --
|
||||
import "fmt"
|
||||
|
||||
$s = fmt.printf("%v", func($x) {
|
||||
len($x)
|
||||
}("helloworld")) # inline lambda call
|
||||
|
||||
test [$s,] {}
|
||||
-- OUTPUT --
|
||||
Vertex: test[10]
|
||||
10
lang/interpret_test/TestAstFunc2/call-inline-lambda4.txtar
Normal file
10
lang/interpret_test/TestAstFunc2/call-inline-lambda4.txtar
Normal file
@@ -0,0 +1,10 @@
|
||||
-- main.mcl --
|
||||
import "fmt"
|
||||
|
||||
$s = fmt.printf("%v", func($x) {
|
||||
len($x)
|
||||
}(func($x){ $x }("helloworld"))) # inline lambda call as an arg to another
|
||||
|
||||
test [$s,] {}
|
||||
-- OUTPUT --
|
||||
Vertex: test[10]
|
||||
Reference in New Issue
Block a user