diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt index a27d125..622d0d7 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt @@ -622,6 +622,8 @@ class Compiler( var endTokenType: Token.Type? = null val startPos = cc.savePos() + cc.skipWsTokens() + while (endTokenType == null) { var t = cc.next() when (t.type) { @@ -679,7 +681,7 @@ class Compiler( // important: valid argument list continues with ',' and ends with '->' or ')' // otherwise it is not an argument list: - when (val tt = cc.next().type) { + when (val tt = cc.nextNonWhitespace().type) { Token.Type.RPAREN -> { // end of arguments endTokenType = tt diff --git a/lynglib/src/commonTest/kotlin/OOTest.kt b/lynglib/src/commonTest/kotlin/OOTest.kt index c6ea141..77cff71 100644 --- a/lynglib/src/commonTest/kotlin/OOTest.kt +++ b/lynglib/src/commonTest/kotlin/OOTest.kt @@ -106,4 +106,15 @@ class OOTest { } """.trimIndent()) } + + @Test + fun testMultilineConstructor() = runTest { + eval(""" + class Point( + x, + y + ) + assertEquals(Point(1,2), Point(1,2) ) + """.trimIndent()) + } } \ No newline at end of file diff --git a/lynglib/src/commonTest/kotlin/ScriptTest.kt b/lynglib/src/commonTest/kotlin/ScriptTest.kt index bfa8047..6a20147 100644 --- a/lynglib/src/commonTest/kotlin/ScriptTest.kt +++ b/lynglib/src/commonTest/kotlin/ScriptTest.kt @@ -3049,5 +3049,22 @@ class ScriptTest { """.trimIndent()) } + @Test + fun testMultilineFnDeclaration() = runTest { + eval(""" + fun test( + x = 1, + y = 2 + ) { + x * y + } + assertEquals( 10, test(5) ) + assertEquals( 42, test( + 6, + 7 + ) ) + """.trimIndent()) + } + } \ No newline at end of file