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

Import Error Handling #1394

Closed
CruzMolina opened this issue Apr 13, 2019 · 3 comments · Fixed by #1395
Closed

Import Error Handling #1394

CruzMolina opened this issue Apr 13, 2019 · 3 comments · Fixed by #1395
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@CruzMolina
Copy link

CruzMolina commented Apr 13, 2019

What's your issue about?

Currently vyper does not provide meaningful errors when incorrectly attempting imports.

When attempting to compile an incorrect relative import, such as:

# myContract.vy

# foobar.vy does not exist or is named foo_bar.vy
import foobar as FooBar

stored_data: uint256

@public
def set(new_value : uint256):
    self.stored_data = new_value

@public
@constant
def get() -> uint256:
    return self.stored_data

Calling vyper myContract.vy returns:

IndexError: tuple index out of range

How can it be fixed?

When comparing the behavior of vyper to solc, given a contract such as:

// myContract.sol
pragma solidity >=0.4.0 <0.7.0;

// foobar.sol doesn't exist or was renamed to foo_bar.sol
import "./foobar.sol";

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

Calling solc myContract.sol returns:

myContract.sol:5:1: Error: Source "foobar.sol" not found: File outside of allowed directories.
import "./foobar.sol";
^--------------------^

Conversely, calling solc myContract.sol --allow-paths . returns:

myContract.sol:5:1: Error: Source "foobar.sol" not found: File not found.
import "./foobar.sol";
^--------------------^

I imagine something in a similar vein would be a useful feature for vyper to have.

@jacqueswww jacqueswww added the bug Bug that shouldn't change language semantics when fixed. label Apr 15, 2019
@jacqueswww
Copy link
Contributor

@CruzMolina there was an error in the error message, fixed in #1395 if you'd like to test.

@CruzMolina
Copy link
Author

Sweet, thanks @jacqueswww !

@fubuloubu fubuloubu changed the title VIP: Import Error Handling Import Error Handling Apr 22, 2019
@fubuloubu
Copy link
Member

Changed this to a bug report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants