Skip to content

Commit

Permalink
Fix paths in nested relative includes
Browse files Browse the repository at this point in the history
Fixes #1321
  • Loading branch information
yav committed Feb 8, 2022
1 parent 2d1f2c1 commit a53b24b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Cryptol/Parser/NoInclude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ resolveInclude lf = pushPath lf $ do
case parseProgramWith (defaultConfig { cfgSource = thing lf, cfgPreProc = guessPreProc (thing lf) }) source of

Right prog -> do
Program ds <- withIncPath (thing lf) (noIncludeProgram prog)
Program ds <-
do path <- fromIncPath (thing lf)
withIncPath path (noIncludeProgram prog)
return ds

Left err -> M (raise [IncludeParseError err])
Expand Down
4 changes: 4 additions & 0 deletions tests/modsys/relative-include/A/B/C.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module A::B::C where
import A::B::D::E::F
include "G/H.pcry" // succeeds when run from `test/`

2 changes: 2 additions & 0 deletions tests/modsys/relative-include/A/B/D/E/F.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module A::B::D::E::F where
x = 1
2 changes: 2 additions & 0 deletions tests/modsys/relative-include/A/B/G/H.pcry
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
y = 2
include "I.pcry"
1 change: 1 addition & 0 deletions tests/modsys/relative-include/A/B/G/I.pcry
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z = 3
1 change: 1 addition & 0 deletions tests/modsys/relative-include/relative-include.icry
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:m A::B::C
4 changes: 4 additions & 0 deletions tests/modsys/relative-include/relative-include.icry.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Loading module Cryptol
Loading module Cryptol
Loading module A::B::D::E::F
Loading module A::B::C

0 comments on commit a53b24b

Please sign in to comment.