Skip to content

Commit

Permalink
Fixed type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Oct 16, 2024
1 parent 5a23e5a commit 55161db
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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;");



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;");

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;};");
Expand Down Expand Up @@ -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];");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\";
");
Expand All @@ -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];
");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
module lang::rascalcore::compile::Examples::Tst0

&T bar(&T() f) = f();

str foo()
= bar(int() {
return 0;
});

0 comments on commit 55161db

Please sign in to comment.