From 55161dbeca7552a4b36d4e034071c14b4bc1b3bc Mon Sep 17 00:00:00 2001 From: paulklint Date: Wed, 16 Oct 2024 10:47:22 +0200 Subject: [PATCH] Fixed type errors --- .../check/tests/AssignmentTCTests.rsc | 2 +- .../check/tests/DataDeclarationTCTests.rsc | 4 +-- .../rascalcore/check/tests/OperatorTests.rsc | 4 +-- .../rascalcore/check/tests/PatternTCTests.rsc | 28 +++++++++---------- .../check/tests/SyntaxDeclarationTCTests.rsc | 8 +++--- .../lang/rascalcore/compile/Examples/Tst0.rsc | 7 ----- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/AssignmentTCTests.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/AssignmentTCTests.rsc index 0eb73cda..df6f21fd 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/AssignmentTCTests.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/AssignmentTCTests.rsc @@ -98,7 +98,7 @@ test bool SLICE9() = unexpectedType("void main(){ lst = [0,1,2,3,4,5]; lst[1,\"a test bool SLICE10() = checkOK("void main(){ s = \"abcdefg\"; s[1..3] = \"x\"; }"); test bool SLICE11() = checkOK("void main(){ s = \"abcdefg\"; s[1..3] += \"x\"; }"); -test bool SLICE11() = unexpectedType("void main(){ s = \"abcdefg\"; s[1..3] += 10; }"); +test bool SLICE12() = unexpectedType("void main(){ s = \"abcdefg\"; s[1..3] += 10; }"); test bool FIELD1() = checkModuleOK(" module FIELD1 diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/DataDeclarationTCTests.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/DataDeclarationTCTests.rsc index 5f77193b..422298e3 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/DataDeclarationTCTests.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/DataDeclarationTCTests.rsc @@ -248,7 +248,7 @@ test bool A2b() { } test bool A3a() { - writeModule("module A"," + writeModule("module A data D = d1(int n, bool b = false); data D = d2(str s, int m = 0);"); writeModule("module B @@ -352,7 +352,7 @@ test bool C2() { writeModule("module B import A; data D(bool B = false) = d3(bool f, str t = \"a\");"); - return checkModuleOKwriteModule(" + return checkModuleOK(" module C3 import B; diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/OperatorTests.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/OperatorTests.rsc index ab1fa089..7115cf64 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/OperatorTests.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/OperatorTests.rsc @@ -65,7 +65,7 @@ test bool JOINSR1() = checkOK("rel[int,int,bool] r = {\<1,10\>} join {true};"); test bool JOINSR2() = checkOK("rel[bool,int,int] r = {true} join {\<1,10\>};"); -test bool JOINSR1() = unexpectedType(" rel[int,int,bool] r = {\<1,10\>} join true;"); +test bool JOINSR3() = unexpectedType(" rel[int,int,bool] r = {\<1,10\>} join true;"); // //-- addition @@ -80,7 +80,7 @@ test bool ADD8() = checkOK("set[int] st = 1 + {3,4};"); test bool ADD9() = checkOK("set[int] st = {1,2} + 3;"); test bool ATP1() = checkOK("tuple[int,str,int,bool] tp = \<1,\"a\"\> + \<2, true\>;"); -test bool ATP1() = checkOK("tuple[int a, str b, int c, bool d] tp = \<1,\"a\"\> + \<2, true\>; int n = tp.a; bool x = tp. d;"); +test bool ATP2() = checkOK("tuple[int a, str b, int c, bool d] tp = \<1,\"a\"\> + \<2, true\>; int n = tp.a; bool x = tp. d;"); diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/PatternTCTests.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/PatternTCTests.rsc index f249ce29..03718d2b 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/PatternTCTests.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/PatternTCTests.rsc @@ -26,7 +26,7 @@ test bool matchListError1() = redeclaredVariable("list[int] x = [1,2,3]; [1, *in test bool matchListErrorRedeclaredSpliceVar1() = redeclaredVariable("list[int] x = [1,2,3];[1, * int L, * int L] := x;"); -test bool matchListError22() = checkOK("list[int] l = [1,2,3]; [1, list[str] L, 2] := l; "); +test bool matchListError2() = checkOK("list[int] l = [1,2,3]; [1, list[str] L, 2] := l; "); test bool matchBoolIntError1() = cannotMatch("true !:= 1;"); @@ -118,23 +118,23 @@ test bool noMatchTupleArityError() = cannotMatch("\<1\> !:= \<1,2\>;"); test bool matchSetStringError() = cannotMatch("{1} := \"a\";"); -test bool matchListError1() = checkOK("list[int] x = [1,2,3]; [1, *list[int] L, 2, list[int] M] !:= x;"); // DISCUSS, was: cannotMatch +test bool matchListError3() = checkOK("list[int] x = [1,2,3]; [1, *list[int] L, 2, list[int] M] !:= x;"); // DISCUSS, was: cannotMatch -test bool matchListError2() = unexpectedDeclaration("!([1, list[int] L, 2, list[int] L] := [1,2,3]);"); +test bool matchListError4() = unexpectedDeclaration("!([1, list[int] L, 2, list[int] L] := [1,2,3]);"); -test bool matchListError3() = checkOK("!([1, list[str] L, 2] := [1,2,3]);"); // DISCUSS, was: cannotMatch +test bool matchListError5() = checkOK("!([1, list[str] L, 2] := [1,2,3]);"); // DISCUSS, was: cannotMatch -test bool matchListError4() = cannotMatch("str S = \"a\"; [1, S, 2] !:= [1,2,3];"); +test bool matchListError6() = cannotMatch("str S = \"a\"; [1, S, 2] !:= [1,2,3];"); -test bool matchListError5() = checkOK("list[int] x = [1,2,3] ; [1, str S, 2] := x;"); // DISCUSS, was: cannotMatch +test bool matchListError7() = checkOK("list[int] x = [1,2,3] ; [1, str S, 2] := x;"); // DISCUSS, was: cannotMatch -test bool matchListError6() = cannotMatch("str S = \"a\"; [1, S, 2] !:= [1,2,3];"); +test bool matchListError8() = cannotMatch("str S = \"a\"; [1, S, 2] !:= [1,2,3];"); -test bool matchListError7() = cannotMatch("str S = \"a\"; list[int] x = [1,2,3]; [1, S, 2] := x;"); +test bool matchListError9() = cannotMatch("str S = \"a\"; list[int] x = [1,2,3]; [1, S, 2] := x;"); -test bool matchListError8() = cannotMatch("list[str] S = [\"a\"]; [1, S, 2] !:= [1,2,3];"); +test bool matchListError10() = cannotMatch("list[str] S = [\"a\"]; [1, S, 2] !:= [1,2,3];"); -test bool matchListError9() = cannotMatch("list[str] S = [\"a\"]; list[int] x = [1,2,3]; [1, S, 2] := x;"); +test bool matchListError11() = cannotMatch("list[str] S = [\"a\"]; list[int] x = [1,2,3]; [1, S, 2] := x;"); test bool RecursiveDataTypeNoPossibleHiddenRecursion() = cannotMatchInModule(" module RecursiveDataTypeNoPossibleHiddenRecursion @@ -286,7 +286,7 @@ test bool If3() = checkOK("{ if(int x := 1 && x == 1 ) x + 1; };"); test bool If4() = unexpectedDeclaration("{ if(int x := 1 && int x := 2 && x == 1 ) x + 1; };"); test bool If5() = checkOK("{ if(int x := 1 && int y := 2 && x == 1 ) x + y; };"); -test bool If5() = unexpectedType("{ if(int x := 1 && int y := 2 && x == 1 ) x + y; else y;};"); +test bool If6() = unexpectedType("{ if(int x := 1 && int y := 2 && x == 1 ) x + y; else y;};"); test bool IfU1() = checkOK("{ if(x := 1) x + 1; };"); test bool IfU2() = unexpectedType("{ if(x := 1) x + 1; else x + 2;};"); @@ -316,9 +316,9 @@ test bool TU2() = checkOK("[*int _] := [1];"); test bool TN1() = checkOK("[int X] := [1];"); test bool TN2() = checkOK("[*int X] := [1];"); -test bool U1() = checkOK("[X] := [1];"); -test bool U2() = checkOK("[X*] := [1];"); -test bool U3() = checkOK("[*X] := [1];"); +test bool U4() = checkOK("[X] := [1];"); +test bool U5() = checkOK("[X*] := [1];"); +test bool U6() = checkOK("[*X] := [1];"); test bool S1() = checkOK("[*X,*_] := [1];"); diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/SyntaxDeclarationTCTests.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/SyntaxDeclarationTCTests.rsc index 52a8171e..86e29b3b 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/SyntaxDeclarationTCTests.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/SyntaxDeclarationTCTests.rsc @@ -357,8 +357,8 @@ test bool RegexpInKeywordOk() = checkModuleOK(" keyword Keywords = \"if\" | \"then\" | [a-z]+; "); -test bool NonterminalInKeywordOk() = checkModuleOK(" - module NonterminalInKeywordOk +test bool NonterminalInKeywordOk1() = checkModuleOK(" + module NonterminalInKeywordOk1 keyword K = \"a\" | B; syntax B = \"b\" | \"bb\" | \"bbb\"; "); @@ -369,8 +369,8 @@ test bool RecursiveNonterminalInKeywordOk() = checkModuleOK(" syntax B = \"b\" | \"bb\" | \"bbb\" | K; "); -test bool NonterminalInKeywordOk() = checkModuleOK(" - module NonterminalInKeywordOk +test bool NonterminalInKeywordOk2() = checkModuleOK(" + module NonterminalInKeywordOk2 keyword K = \"a\" | B; syntax B = \"b\" | \"bb\" | [a-z]; "); diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc index ea332fc9..43c69c2a 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc @@ -1,8 +1 @@ module lang::rascalcore::compile::Examples::Tst0 - -&T bar(&T() f) = f(); - -str foo() - = bar(int() { - return 0; - }); \ No newline at end of file