Skip to content

Commit

Permalink
#43 Files that have the same name as those in SparrowImplicitLib cann…
Browse files Browse the repository at this point in the history
…ot compile
  • Loading branch information
lucteo committed Sep 7, 2019
1 parent 9953189 commit c28573f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Nest/src/Api/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,22 @@ Nest_SourceCode* _handleImport(const ImportInfo& import) {
}
}

// Test to see if the file is relative to some of the import paths
for (const string& importPath : _settings.importPaths_) {
ImportInfo importRel = import;
importRel.filename_ = path(importPath) / p;
res = _handleImportFile(importRel);
if (res.first)
return res.second;
}

// Test to see if the file is relative to the current path
ImportInfo importRel = import;
importRel.filename_ = _curPath / p;
res = _handleImportFile(importRel);

// Test to see if the file is relative to some of the import paths
if (!res.first) {
for (const string& importPath : _settings.importPaths_) {
ImportInfo importRel = import;
importRel.filename_ = path(importPath) / p;
res = _handleImportFile(importRel);
if (res.first)
return res.second;
}
}

if (!res.first)
REP_ERROR(NOLOC, "Cannot find input file: %1%") % import.filename_.string();
return res.second;
Expand Down
12 changes: 12 additions & 0 deletions tests/Bugs/test.spr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//!!

// Test purpose: make sure we are not using files from std lib

import std.ranges

fun sprMain
cout << 'OK\n'

/*<<<Running()
OK
>>>*/
1 change: 1 addition & 0 deletions tests/tests.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Bugs/VectorOfCtClass.spr: Bugs - vectors of CT-only classes
Bugs/WhileVarCond.spr: Bugs - while condition is a variable or a reference
Bugs/GenericWithCtConcept.spr: Bugs - generic with CT concept
Bugs/CastOnAssignment.spr: Bugs - cast on assignment
Bugs/test.spr: Bugs - using local files instead of std lib ones

# AlgoProblems/P1_Collatz.spr: Algo problems - P1. Collatz sequences
Examples/Power.spr: Examples: Powers
Expand Down

0 comments on commit c28573f

Please sign in to comment.