-
Notifications
You must be signed in to change notification settings - Fork 213
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
Make import_no Optional #1443
Make import_no Optional #1443
Conversation
Signed-off-by: Ben Kushigian <[email protected]>
e1b3f95
to
ab7d6a4
Compare
&polkadot, | ||
&cache.get_import_path(file.import_no.unwrap()).unwrap().1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is imported via import path so these asserts should assert!(file.import_no.is_none());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand, "createpair.sol" is resolved by file resolver by walking over import paths. If I don't add polkadot as an import path to the file resolver then tests fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i. when no import path is used, and
Yes, add a test which removes:
assert!(cache.add_import_path(polkadot.as_path()).is_ok());
ii. "when a file is resolved via relative paths and not via import paths/maps".
Could you expand on these more? For (i), how would I set up a case when no import path is used? For (ii), do you mean in an import statement (likeimport ./blah.sol
)? I have a test that does this (importsintegrations/polkadots/createpair.sol
which has a relative import), but I'm not sure exactly what we want to test.
let path = OsStr::from("examples/polkadot/flipper.sol");
let ns = parse_and_resolve(path, &mut cache, Target::EVM);
src/file_resolver.rs
Outdated
@@ -206,7 +206,7 @@ impl FileResolver { | |||
return Ok(ResolvedFile { | |||
full_path, | |||
base, | |||
import_no: 0, | |||
import_no: Some(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None/copy of parent
src/file_resolver.rs
Outdated
@@ -218,12 +218,12 @@ impl FileResolver { | |||
return Ok(ResolvedFile { | |||
full_path, | |||
base, | |||
import_no: 0, | |||
import_no: Some(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy of parent import_no
@@ -236,7 +236,7 @@ impl FileResolver { | |||
return Ok(ResolvedFile { | |||
full_path, | |||
base, | |||
import_no: 0, | |||
import_no: Some(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy of import_no in cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where can I get this? I don't think this is accessible through FileResolver (it's in File which is stored in Namespace).
@seanyoung just wanted to follow up on this PR. I left a couple replies above. |
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
I've looked at this and wrote a new PR #1465 which solves a number of issues including |
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang#1443 Signed-off-by: Sean Young <[email protected]>
…no (#1465) When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of #1443 Signed-off-by: Sean Young <[email protected]> Co-authored-by: Cyrill Leutwiler <[email protected]>
Fixed by #1465 |
…no (#1465) When importing in Solidity, `import "foo";` does not check path relative to the currrent file, only `import "./foo";` does. This work is also a re-write of hyperledger-solang/solang#1443 Signed-off-by: Sean Young <[email protected]> Co-authored-by: Cyrill Leutwiler <[email protected]>
This PR does 2 things:
ResolvedFile::import_no
anOption<usize>
This is a first attempt, I imagine there are a few things that can be improved.
Possible issues include:
import_no
s are set to0
when no import is used per this conversation; in this case, theimport_no
should be set toNone
. However, I imagine others are set to 0 because it is the first import that is performed. I currently just changed all literalimport_no: 0
toimport_no: Some(0)
to get it to type check, but I'm guessing they may actually want to beimport_no: None
.Could you expand on these more? For (i), how would I set up a case when no import path is used? For (ii), do you mean in an import statement (like
import ./blah.sol
)? I have a test that does this (importsintegrations/polkadots/createpair.sol
which has a relative import), but I'm not sure exactly what we want to test.