diff --git a/src/Cryptol/Parser/NoInclude.hs b/src/Cryptol/Parser/NoInclude.hs index 336f2e266..418fb86cb 100644 --- a/src/Cryptol/Parser/NoInclude.hs +++ b/src/Cryptol/Parser/NoInclude.hs @@ -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]) diff --git a/tests/modsys/relative-include/A/B/C.cry b/tests/modsys/relative-include/A/B/C.cry new file mode 100644 index 000000000..262792763 --- /dev/null +++ b/tests/modsys/relative-include/A/B/C.cry @@ -0,0 +1,4 @@ +module A::B::C where +import A::B::D::E::F +include "G/H.pcry" // succeeds when run from `test/` + diff --git a/tests/modsys/relative-include/A/B/D/E/F.cry b/tests/modsys/relative-include/A/B/D/E/F.cry new file mode 100644 index 000000000..f386e43c1 --- /dev/null +++ b/tests/modsys/relative-include/A/B/D/E/F.cry @@ -0,0 +1,2 @@ +module A::B::D::E::F where +x = 1 diff --git a/tests/modsys/relative-include/A/B/G/H.pcry b/tests/modsys/relative-include/A/B/G/H.pcry new file mode 100644 index 000000000..f528fb201 --- /dev/null +++ b/tests/modsys/relative-include/A/B/G/H.pcry @@ -0,0 +1,2 @@ +y = 2 +include "I.pcry" diff --git a/tests/modsys/relative-include/A/B/G/I.pcry b/tests/modsys/relative-include/A/B/G/I.pcry new file mode 100644 index 000000000..b67ca6a5d --- /dev/null +++ b/tests/modsys/relative-include/A/B/G/I.pcry @@ -0,0 +1 @@ +z = 3 diff --git a/tests/modsys/relative-include/relative-include.icry b/tests/modsys/relative-include/relative-include.icry new file mode 100644 index 000000000..2b64f2e39 --- /dev/null +++ b/tests/modsys/relative-include/relative-include.icry @@ -0,0 +1 @@ +:m A::B::C diff --git a/tests/modsys/relative-include/relative-include.icry.stdout b/tests/modsys/relative-include/relative-include.icry.stdout new file mode 100644 index 000000000..a2ed937d4 --- /dev/null +++ b/tests/modsys/relative-include/relative-include.icry.stdout @@ -0,0 +1,4 @@ +Loading module Cryptol +Loading module Cryptol +Loading module A::B::D::E::F +Loading module A::B::C