diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectPattern.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectPattern.rsc index 963fa6fb..dc2ea20a 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectPattern.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectPattern.rsc @@ -291,7 +291,13 @@ void collect(current: (Pattern) ` : `, Collector c){ } else { c.push(patternNames, ); scope = c.getScope(); - c.define(uname, formalOrPatternFormal(c), name, defLub([pattern], AType(Solver s) { return getPatternType(pattern, avalue(), scope, s); })); + c.define(uname, formalOrPatternFormal(c), name, + defLub([pattern], AType(Solver s) { + try{ + return s.getType(pattern); + } catch _: + return getPatternType(pattern, avalue(), scope, s); + })); } collect(pattern, c); } diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc index 891b9f36..214f17f2 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc @@ -1,17 +1,23 @@ module lang::rascalcore::compile::Examples::Tst4 -import IO; +//alias T = tuple[int, str]; +void main() { + //set[tuple[int, str]] r = {}; -data Foo = foo(int x); -list[Foo] foos = [foo(1), foo(2), foo(3)]; + // Error + // `Initialization of `ts1` should be subtype of `rel[int, str]`, found `rel[value, value]`` + //set[tuple[int, str]] ts1 = {t | t: <- r}; + + set[str] a = {}; + set[str] b = { x| t: x <- a}; + + //// No errors + //set[T] ts2 = {t | t <- r}; + //set[T] ts3 = {t | T t:<_, _> <- r}; + //set[T] ts4 = { | <- r}; + //set[T] ts5 = {t | t: <- r}; +} -void f() { - bool foo() = true; - println(foo(x) in foos); - // ^^^ Error: "Expected 0 argument(s), found 1" - } - - //value main() = _f(3); //data Tree;