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

Comments

@CruzMolina
Copy link

@CruzMolina 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

This comment has been minimized.

Copy link
Collaborator

@jacqueswww jacqueswww commented Apr 15, 2019

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

@CruzMolina

This comment has been minimized.

Copy link
Author

@CruzMolina CruzMolina commented Apr 15, 2019

Sweet, thanks @jacqueswww !

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

This comment has been minimized.

Copy link
Member

@fubuloubu fubuloubu commented Apr 22, 2019

Changed this to a bug report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.