Skip to content
Open
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 @@ -177,7 +177,7 @@ tuple[TModel, ModuleStatus] addGrammar(MODID moduleId, set[MODID] imports, set[M
} else {
<found, tm1, ms> = getTModelForModule(m, ms);
if(!found) {
msg = error("Cannot add grammar, tmodel for <m> not found", ms.moduleLocs[moduleId] ? |unknown:///|);
msg = error("Cannot add grammar or tmodel since `<moduleId2moduleName(m)>` is not found", ms.moduleLocs[moduleId] ? |unknown:///|);
ms.messages[moduleId] ? {} += { msg };
tm1 = tmodel(modelName=qualifiedModuleName, messages=[msg]);
return <tm1, ms>;
Expand Down
16 changes: 13 additions & 3 deletions src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ ModuleStatus rascalTModelForLocs(
ms.status[m] += {tpl_uptodate(), checked(), bom_update_needed()};
}
}
} catch rascalTplVersionError(e): ;// m_compatible remains false
} catch rascalTplVersionError(_,_,_,_): {
ms.status[m] += { tpl_version_error() };
// m_compatible remains false
};

compatible_with_all_imports = compatible_with_all_imports && m_compatible;
}
Expand Down Expand Up @@ -328,6 +331,9 @@ ModuleStatus rascalTModelForLocs(
if(!ms.status[inameId]?){
ms.status[inameId] = {};
}
if({tpl_version_error(), rsc_not_found()} <= ms.status[inameId]){
imsgs += error("Rascal TPL version error for `<iname>`, no source found", imod@\loc);
}
if(inameId notin usedModules){
if(iname == "ParseTree" && implicitlyUsesParseTree(ms.moduleLocs[m].path, tm)){
continue check_imports;
Expand Down Expand Up @@ -389,9 +395,13 @@ ModuleStatus rascalTModelForLocs(
for(MODID mid <- topModuleIds){
ms.messages[mid] = { error("Parse error", src) };
}
} catch rascalTplVersionError(str txt):{
} catch rascalTplVersionError(str moduleName, loc tpl, str version, str txt):{
for(MODID mid <- topModuleIds){
ms.messages[mid] = { error("<txt>", ms.moduleLocs[mid] ? |unknown:///|) };
causes = [ info("Module `<moduleName>` has outdated Rascal TPL version <version>, no source found", tpl) ];
ms.messages[mid] ? {} += { error("Import/extend of `<moduleName>` has <txt>",
ms.moduleLocs[mid] ? |unknown:///|,
causes= causes)
};
}
} catch Message msg: {
for(MODID mid <- topModuleIds){
Expand Down
23 changes: 12 additions & 11 deletions src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void checkSupportedByParserGenerator(Tree t, Collector c){
data MStatus =
rsc_not_found()
| tpl_not_found()
| tpl_version_error()
| rsc_changed()
| parsed()
| parse_error()
Expand Down Expand Up @@ -262,8 +263,7 @@ tuple[bool, Module, ModuleStatus] getModuleParseTree(MODID moduleId, ModuleStatu
throw "No src or library module";
}
} catch e: {
println(e);
ms.messages[moduleId] ? {} += {error("Module <qualifiedModuleName> not found", mloc)};
ms.messages[moduleId] ? {} += {error("Module `<qualifiedModuleName>` not found", mloc)};
ms.moduleLocs[moduleId] = mloc;
return <false, dummyModule, ms>;
}
Expand Down Expand Up @@ -420,15 +420,15 @@ tuple[bool, TModel, ModuleStatus] getTModelForModule(MODID moduleId, ModuleStatu
while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != moduleId){
ms = removeOldestTModelFromCache(ms);
}

qualifiedModuleName = moduleId2moduleName(moduleId);
<found, tplLoc> = getTPLReadLoc(moduleId, pcfg);
if(found){
if(traceTPL) println("*** reading tmodel <tplLoc>");
tmVersion = "0.0.0";
try {
tm = readBinaryValueFile(ReifiedTModel, tplLoc);
if(tm.rascalTplVersion? && isValidRascalTplVersion(tm.rascalTplVersion)){
tmVersion = tm.rascalTplVersion;
tmVersion = tm.rascalTplVersion;
if(isValidRascalTplVersion(tmVersion)){
ms.tmodels[moduleId] = tm;
mloc = getRascalModuleLocation(moduleId, ms);
if(isModuleLocationInLibs(mloc, pcfg)){
Expand All @@ -440,15 +440,16 @@ tuple[bool, TModel, ModuleStatus] getTModelForModule(MODID moduleId, ModuleStatu
return <true, tm, ms>;
}
} catch e: {
qualifiedModuleName = moduleId2moduleName(moduleId);
return <false, tmodel(modelName=moduleId2moduleName(moduleId), messages=[error("Cannot read TPL for <qualifiedModuleName>: <e>", tplLoc)]), ms>;
}
msg = "<tplLoc> has outdated Rascal TPL version <tmVersion != "0.0.0" ? tmVersion + " " : "">(required: <getCurrentRascalTplVersion()>)";
println("INFO: <msg>)");
throw rascalTplVersionError(msg);
msg = "outdated Rascal TPL version <tmVersion != "0.0.0" ? tmVersion + " " : "">(required: <getCurrentRascalTplVersion()>)";
throw rascalTplVersionError(qualifiedModuleName, tplLoc, tmVersion, msg);
}
qualifiedModuleName = moduleId2moduleName(moduleId);
return <false, tmodel(modelName=qualifiedModuleName, messages=[error("Cannot read TPL for <qualifiedModuleName>", tplLoc)]), ms>;
mloc = tplLoc;
try {
mloc = getRascalModuleLocation(moduleId, ms);
} catch _: /* ignore when this fails */;
return <false, tmodel(modelName=qualifiedModuleName, messages=[error("Cannot read TPL for <qualifiedModuleName>", mloc)]), ms>;
}

rel[loc from, PathRole r, loc to] getPaths(rel[MODID from, PathRole r, MODID to] paths, ModuleStatus ms){
Expand Down
13 changes: 11 additions & 2 deletions src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,19 @@ ModuleStatus getImportAndExtendGraph(MODID moduleId, ModuleStatus ms){
return completeModuleStatus(ms);
}
}
} catch rascalTplVersionError(_):
; // Need to recheck since TModel uses incompatible TPL version
} catch rascalTplVersionError(str moduleName, loc tplLoc, str version, str txt):{
ms.status[moduleName2moduleId(moduleName)] += { tpl_version_error() };
// Need to recheck since TModel uses incompatible TPL version
}

if(rsc_not_found() in ms.status[moduleId]){
if(tpl_version_error() in ms.status[moduleId]){
iName = moduleId2moduleName(moduleId);
for(<MODID m, _, moduleId> <- ms.paths){
mName = moduleId2moduleName(m);
ms.messages[m] ? {} += { error("For import/extend `<iName>` of `<mName>` is no source available and TPL has wrong version", m) };
}
}
return ms;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ Project removeSourceOfModule(str mname, Project pd){
return pd;
}

Project removeTPLOfModule(str mname, Project pd){
remove(bin(pd.name) + "rascal/$<mname>.tpl", recursive=true);
return pd;
}

Project setTPLVersionOfProject(str v, Project pd){
try {
for(loc f <- find(bin(pd.name), "tpl")){
Expand Down Expand Up @@ -175,6 +180,7 @@ bool checkExpectNoErrors(str mname, PathConfig pcfg, list[Project] remove = []){
}

bool expectErrors(list[ModuleMessages] modMsgs, list[str] expected){
if(verbose) iprintln(modMsgs);
errors = {e | /e:error(_,_) := modMsgs};

for(e <- errors){
Expand Down Expand Up @@ -382,7 +388,35 @@ test bool incompatibleWithBinaryLibraryDueToTPLVersion(){


lib = removeSourceOfModule("M1", lib); // remove source of M1 completely, to be sure
lib = setTPLVersionOfProject("0.0.0", lib); // set rascalTplVersion to incompatible version number
lib = setTPLVersionOfProject("0.0.1", lib); // set rascalTplVersion to incompatible version number

// Create project "client" and module "M2" and then compile "M2"
// "client" uses "lib" as binary library
clientName = "client";
client = createProject(clientName,
("M2": "import M1; // binary import
'int main() = f(42); // compatible call fo f
"),
createPathConfig(clientName)
[libs = [bin(libName)] ]
);
return checkExpectErrors("M2", ["outdated Rascal TPL version"], client.pcfg, remove = [lib, client]);
}



test bool removedTPLInBinaryLibrary(){
// Create project "lib" and module "M1" and then compile "M1"
libName = "lib";
lib = createProject(libName,
("M1": "int f(int n) = n;"),
createPathConfig(libName)
);
assert checkExpectNoErrors("M1", lib.pcfg);


lib = removeSourceOfModule("M1", lib); // remove source of M1 completely, to be sure
lib = removeTPLOfModule("M1", lib); // remove M1's tpl file

// Create project "client" and module "M2" and then compile "M2"
// "client" uses "lib" as binary library
Expand All @@ -394,7 +428,7 @@ test bool incompatibleWithBinaryLibraryDueToTPLVersion(){
createPathConfig(clientName)
[libs = [bin(libName)] ]
);
return checkExpectErrors("M2", ["has outdated Rascal TPL version"], client.pcfg, remove = [lib, client]);
return checkExpectErrors("M2", ["Module `M1` not found"], client.pcfg, remove = [lib, client]);
}

// Scenarios with outdated TPL versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ import Message;
data Exception
= CompileTimeError(Message msg)
| InternalCompilerError(Message msg)
| rascalTplVersionError(str txt)
| rascalTplVersionError(str moduleName, loc tpl, str version, str txt)
;
Loading