fixed inline map splats expansion in function calls
This commit is contained in:
parent
f6d51e9b94
commit
3dfe98a93d
@ -1044,7 +1044,7 @@ class Compiler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Token.Type.ELLIPSIS -> {
|
Token.Type.ELLIPSIS -> {
|
||||||
parseStatement()?.let { args += ParsedArgument(it, t.pos, isSplat = true) }
|
parseExpression()?.let { args += ParsedArgument(it, t.pos, isSplat = true) }
|
||||||
?: throw ScriptError(t.pos, "Expecting arguments list")
|
?: throw ScriptError(t.pos, "Expecting arguments list")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,7 +1110,7 @@ class Compiler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Token.Type.ELLIPSIS -> {
|
Token.Type.ELLIPSIS -> {
|
||||||
parseStatement()?.let { args += ParsedArgument(it, t.pos, isSplat = true) }
|
parseExpression()?.let { args += ParsedArgument(it, t.pos, isSplat = true) }
|
||||||
?: throw ScriptError(t.pos, "Expecting arguments list")
|
?: throw ScriptError(t.pos, "Expecting arguments list")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4284,4 +4284,17 @@ class ScriptTest {
|
|||||||
|
|
||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testAutoSplatArgs() = runTest {
|
||||||
|
eval("""
|
||||||
|
fun tf(x, y, z) {
|
||||||
|
"x=%s, y=%s, z=%s"(x,y,z)
|
||||||
|
}
|
||||||
|
assertEquals(tf(1, 2, 3), "x=1, y=2, z=3")
|
||||||
|
val a = { x: 3, y: 4, z: 5 }
|
||||||
|
assertEquals(tf(...a), "x=3, y=4, z=5")
|
||||||
|
assertEquals(tf(...{ x: 3, y: 4, z: 50 }), "x=3, y=4, z=50")
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user