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

Support for diagnostic notes without file locations #1308

Open
xermicus opened this issue May 11, 2023 · 4 comments
Open

Support for diagnostic notes without file locations #1308

xermicus opened this issue May 11, 2023 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@xermicus
Copy link
Contributor

Right now we can not display file notes if the error originates in a builtin. Example:

import "substrate";
contract Foo {
   function chain_extension() public pure {}
}

Results in

thread 'main' panicked at 'internal error: entered unreachable code: note without file position', src/sema/diagnostics.rs:171:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We could just remove the panic and drop the note:

warning: chain_extension is already defined as a function
  ┌─ /home/glow/code/solang/test.sol:3:13
  │
3 │    function chain_extension() public pure {}
  │             ^^^^^^^^^^^^^^^

However instead of just dropping the note, it would be nice to support notes for code without a source file.

@seanyoung
Copy link
Contributor

seanyoung commented May 11, 2023

In this case, the note is there to point to the location of the function definition, which doesn't exist but there is no location. So, the note should not be generated for builtin functions. Having said that, the error message itself should probably say "{} is already defined as a builtin function".

@xermicus
Copy link
Contributor Author

Ah yes this is a good idea

@xermicus xermicus added good first issue Good for newcomers bug Something isn't working labels May 11, 2023
@xermicus
Copy link
Contributor Author

Actually, I think we can keep the note but it should point to the import "substrate"; statement?

@seanyoung
Copy link
Contributor

Actually, I think we can keep the note but it should point to the import "substrate"; statement?

Even better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants