diff --git a/src/main/java/ch/njol/skript/lang/function/Parameter.java b/src/main/java/ch/njol/skript/lang/function/Parameter.java index d8682220d77..b77a95b8c5d 100644 --- a/src/main/java/ch/njol/skript/lang/function/Parameter.java +++ b/src/main/java/ch/njol/skript/lang/function/Parameter.java @@ -42,7 +42,7 @@ public final class Parameter { - public final static Pattern PARAM_PATTERN = Pattern.compile("\\s*(.+?)\\s*:(?=[^:]*$)\\s*(.+?)(?:\\s*=\\s*(.+))?\\s*"); + public final static Pattern PARAM_PATTERN = Pattern.compile("^\\s*([^:(){}\",]+?)\\s*:\\s*([a-zA-Z ]+?)\\s*(?:\\s*=\\s*(.+))?\\s*$"); /** * Name of this parameter. Will be used as name for the local variable diff --git a/src/test/skript/tests/regressions/pull-6361-function-param.sk b/src/test/skript/tests/regressions/pull-6361-function-param.sk new file mode 100644 index 00000000000..81ef44a8d98 --- /dev/null +++ b/src/test/skript/tests/regressions/pull-6361-function-param.sk @@ -0,0 +1,46 @@ +# TODO add these to tests once structure test parsing is implemented (https://github.com/SkriptLang/Skript/pull/6291) +# function testA(loc): location, previoustype(): text): +# broadcast "a" + +# function testB(loc(: location, previoustype): text): +# broadcast "b" + +# function testE(loc: location, previoustyp): returns text: object = (")")): +# broadcast "%{_loc}% %{_previoustyp): returns text}%" + +# function this((function should(not: exist) returns text:) ? object : text) :: text: +# return {_(function should(not: exist) returns text:) ? object } + + +# function never(gonna: give = (you - up)): and function never(gonna: let, you: down) :: text): +# broadcast {@magic} + +# function testA3(previoustyp): returns text: object = (")")): +# broadcast 2 + + +function test_English(test: text) :: text: + return {_test} + +function test_Arabic(تجربة: text) :: text: + return {_تجربة} + +function test_Japanese(テスト: text) :: text: + return {_テスト} + +function test_Greek(δοκιμή: text) :: text: + return {_δοκιμή} + +function test_Thai(ทดสอบ: text) :: text: + return {_ทดสอบ} + +function test_German(prüfen: text) :: text: + return {_prüfen} + +test "function parameter names": + assert test_English("text") = "text" with "Function 'test_English' failed function parameter name test" + assert test_Arabic("text") = "text" with "Function 'test_Arabic' failed function parameter name test" + assert test_Japanese("text") = "text" with "Function 'test_Japanese' failed function parameter name test" + assert test_Greek("text") = "text" with "Function 'test_Greek' failed function parameter name test" + assert test_Thai("text") = "text" with "Function 'test_Thai' failed function parameter name test" + assert test_German("text") = "text" with "Function 'test_German' failed function parameter name test" \ No newline at end of file