Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,10 @@ void collect(current: (FunctionDeclaration) `<FunctionDeclaration decl>`, Collec

c.enterLubScope(decl);
collect(decl.tags, c);
<tpnames, tpbounds> = collectSignature(decl.signature, c);
//println("tpnames: <tpnames>");
//iprintln("tpbounds:"); iprintln(tpbounds);
//
scope = c.getScope();
c.setScopeInfo(scope, functionScope(), signatureInfo(signature.\type));


<tpnames, tpbounds> = collectSignature(decl.signature, c);
dt = defType([signature], AType(Solver s) {
ft = s.getType(signature);

Expand Down Expand Up @@ -477,7 +473,7 @@ tuple[set[str], rel[str,Type]] collectSignature(Signature signature, Collector c
rtU = updateBounds(rt, minB);
formalsList = [ updateBounds(fm, minB) | fm <- formalsList ];
kwFormalsList = [ kwf[fieldType = updateBounds(kwf.fieldType, minB)] | kwf <- computeKwFormals(kwFormals, s) ];
ft = afunc(rt, formalsList, kwFormalsList);
ft = afunc(rtU, formalsList, kwFormalsList);
//ft = updateBounds(afunc(s.getType(returnType), formalsList, computeKwFormals(kwFormals, s)), minB);
return ft;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,21 @@ void collect(current: (Pattern) `<Type tp> <Name name>`, Collector c){
if(tp is function) c.enterScope(current);
collect(tp, c);
if(tp is function) c.leaveScope(current);

c.calculate("typed variable pattern", current, [tp], AType(Solver s){ return s.getType(tp)[alabel=uname]; });
calcDeps = [tp];
functionScopes = c.getScopeInfo(functionScope());
if(!isEmpty(functionScopes)){
for(<_, scopeInfo> <- functionScopes){
if(signatureInfo(Type returnType) := scopeInfo){
calcDeps += returnType;
break;
} else {
throw rascalCheckerInternalError(getLoc(current), "Inconsistent info from function scope: <scopeInfo>");
}
}
}
c.calculate("typed variable pattern", current, calcDeps, AType(Solver s){ return s.getType(tp)[alabel=uname]; });


if(!isWildCard(uname)){
c.push(patternNames, <uname, getLoc(name)>);
orScopes = c.getScopeInfo(orScope());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,83 @@
module lang::rascalcore::compile::Examples::Tst5

import IO;
import String;
import Location;
import Message;
import Set;
import util::Reflective;
import ParseTree;
import lang::rascalcore::check::RascalConfig;

import lang::rascalcore::check::Checker;
import lang::rascal::\syntax::Rascal;
loc root = |memory://e0711529-477e-4a4c-b44b-44b00157728eXXX|;

PathConfig pcfg = pathConfig(
srcs = [root + "src"],
bin = root + "bin",
libs = []
);
// this name matters
str moduleName = "TestModule612d1";

loc writeModule() {
loc moduleLoc = pcfg.srcs[0] + "<moduleName>.rsc";
// the spaces before &T seems to matter?
writeFile(moduleLoc,
"module TestModule612d1\r\n \r\n &T \<: int f(&T \<: num _) = 1;"
);
return moduleLoc;
}



set[Message] getErrorMessages(ModuleStatus r)
= { m | m <- getAllMessages(r), m is error };

set[Message] getWarningMessages(ModuleStatus r)
= { m | m <- getAllMessages(r), m is warning };

set[Message] getAllMessages(ModuleStatus r)
= { m | mname <- r.messages, m <- r.messages[mname] };

bool typecheckModule(loc m) {
status = rascalTModelForLocs([m], rascalCompilerConfig(pcfg)[infoModuleChecked=true][verbose=true], dummy_compile1);
println("All messages:");
iprintln(getAllMessages(status));
if (e <- getErrorMessages(status)) {
println("Errors typechecking: ");
iprintln(getErrorMessages(status));
println("❌ Typecheck failed");
return false;
}
else {
println("✅ Typecheck success");
return true;
}
}

void findCollission(loc l) {
m = parseModule(l);
locs = [ t.src | /Tree t := m, t.src?];
println("Found <size(locs)> locs");
locsSet = {*locs};
println("Became: <size(locsSet)> locs when putting in set");
for (l <- locs) {
bool found = false;
for (l2 <- locsSet, "<l2>" == "<l>") {
found = true;
}
if (!found) {
println("❌ <l> got dropped from set");
}
}
}


void main() {
remove(root, recursive = true);
l = writeModule();
typecheckModule(l);
findCollission(l);
}
Loading