Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested relative include? #1321

Closed
WeeknightMVP opened this issue Jan 29, 2022 · 1 comment · Fixed by #1323
Closed

Nested relative include? #1321

WeeknightMVP opened this issue Jan 29, 2022 · 1 comment · Fixed by #1323
Assignees
Labels
bug Something not working correctly parser Issues with lexing or parsing.

Comments

@WeeknightMVP
Copy link

Are relative include paths meant to work within another include?

// test/A/B/C.cry
module A::B::C where
import A::B::D::E::F
include "G/H.pcry"  // succeeds when run from `test/`

// test/A/B/D/E/F.cry
module A::B::D::E::F where
x = 1

// test/A/B/G/H.pcry
y = 2
include "I.pcry"  # fails unless absolute path; no path relative to any parent is found

// test/A/B/G/I.pcry
z = 3
test$ cryptol
...
Cryptol> :m A::B::C  // include "I.pcry"
Loading module Cryptol
Loading module A::B::D::E::F
Loading module A::B::C

`I.pcry` included at G/H.pcry:2:9--2:17 was not found
Cryptol> :m A::B::C  // include "G/I.pcry"
Loading module Cryptol
Loading module A::B::D::E::F
Loading module A::B::C

`G/I.pcry` included at G/H.pcry:2:9--2:19 was not found
Cryptol> :m A::B::C  // include "B/G/I.pcry"
Loading module Cryptol
Loading module A::B::D::E::F
Loading module A::B::C

`B/G/I.pcry` included at G/H.pcry:2:9--2:21 was not found
Cryptol> :m A::B::C  // include "A/B/G/I.pcry"
Loading module Cryptol
Loading module A::B::D::E::F
Loading module A::B::C

`A/B/G/I.pcry` included at G/H.pcry:2:9--2:23 was not found
Cryptol> :m A::B::C  // include "test/A/B/G/I.pcry"
Loading module Cryptol
Loading module A::B::D::E::F
Loading module A::B::C

`test/A/B/G/I.pcry` included at G/H.pcry:2:9--2:28 was not found
Cryptol> :m A::B::C  // include "/.../test/A/B/G/I.pcry"
Loading module Cryptol
Loading module A::B::D::E::F
Loading module A::B::C
A::B::C> 
@yav
Copy link
Member

yav commented Feb 7, 2022

Hello, it's been long enough that I don't remember the thinking behind include, but looking at the source code I'd say this is a bug, as the code already is trying to handle includes relative to other includes. Fortunately, this looks like a simple 1line fix, that I did locally and things seem to work as expected. To help me see what's happening, I also modified the error message to show the path relative to which it was looking for things, which might be a good thing to commit anyway, as it seems like a helpful piece of information.

I'll make a PR later today.

@yav yav self-assigned this Feb 7, 2022
@yav yav added bug Something not working correctly parser Issues with lexing or parsing. labels Feb 7, 2022
yav added a commit that referenced this issue Feb 7, 2022
@yav yav linked a pull request Feb 7, 2022 that will close this issue
yav added a commit that referenced this issue Feb 8, 2022
@yav yav closed this as completed in #1323 Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something not working correctly parser Issues with lexing or parsing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants