Skip to content

Commit

Permalink
The (optional) expression in tags was not properly handled
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Mar 19, 2024
1 parent 7fc1d28 commit 846ce29
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void collect(current: (Declaration) `<Tags tags> <Visibility visibility> <Type v
}

void collect(Tag tg, Collector c){
if(tg has expression){
if(tg is expression){
collect(tg.expression, c);
}
}
Expand All @@ -164,7 +164,7 @@ void collect(current: (Declaration) `<Tags tags> <Visibility visibility> anno <T
dt.md5 = md5Hash("<current>");
if(!isEmpty(tagsMap)) dt.tags = tagsMap;
c.define(pname, annoId(), name, dt);
collect(annoType, onType, c);
collect(tags, annoType, onType, c);
}

// ---- keyword Formal --------------------------------------------------------
Expand Down Expand Up @@ -223,7 +223,7 @@ void collect(current: (FunctionDeclaration) `<FunctionDeclaration decl>`, Collec
c.enterLubScope(decl);
scope = c.getScope();
c.setScopeInfo(scope, functionScope(), returnInfo(signature.\type));
collect(decl.signature, c);
collect(decl.tags, decl.signature, c);

// DefInfo dt = noDefInfo();
// try { // try immediate computation of the function type if all types are already available
Expand Down Expand Up @@ -651,7 +651,7 @@ void collect (current: (Declaration) `<Tags tags> <Visibility visibility> alias
c.define(aliasName, aliasId(), current, defType([base], AType(Solver s) { return s.getType(base); })[md5 = md5Hash("<current>")]);
c.enterScope(current);
collect(base, c);
collect(tags, base, c);
c.leaveScope(current);
}
Expand Down Expand Up @@ -685,5 +685,5 @@ void collect (current: (Declaration) `<Tags tags> <Visibility visibility> alias
return aalias(aliasName, params, s.getType(base));
})[md5 = md5Hash("<current>")]);
collect(typeVars + base, c);
collect(tags, typeVars + base, c);
}
Original file line number Diff line number Diff line change
Expand Up @@ -805,17 +805,18 @@ void collect(current: (Expression) `<Expression lhs> || <Expression rhs>`, Colle
s.requireUnify(abool(), rhs, error(rhs, "Argument of || should be `bool`, found %t", rhs));
});

collect(lhs, c);

introLhs = introducedVars(lhs, c);
introRhs = introducedVars(rhs, c);

collect(lhs, c);

// make common variables available when collecting rhs;
// variables in rhs will use definition from lhs (see CollectPattern: typed variable pattern, qualifiedName pattern)
c.setScopeInfo(c.getScope(), orScope(), orInfo(introLhs));
collect(rhs, c);

// Check that the names introduced in lhs and rhs are the same
// Check that the names introduced in lhs and rhs are the same

common = introLhs & introRhs;
missing = (introLhs - common) + (introRhs - common);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,10 @@ module lang::rascalcore::compile::Examples::Tst5
// && x == "x" && y == "y";
//}

@synopsis{Sort the elements of a list.}

list[&T] sort(list[&T] lst) =
sort(lst, bool (&T a, &T b) { return a < b; } );

@javaClass{org.rascalmpl.library.Prelude}
java list[&T] sort(list[&T] l, bool (&T a, &T b) less) ;

value main(){
myList = [<1,2>,<2,2>];
return sort(myList, bool (<int i, _>, <int j, _>) { return i < j; });
}
import util::Memo;

@memo=expireAfter(minutes=10)
void foo() { }

//value main(){
// if([1, int x] !:= [1]) return x;
Expand Down

0 comments on commit 846ce29

Please sign in to comment.