-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Compiler error does not provide location of error when crossing package boundaries #3997
Comments
If I drop:
… in the other directory, everything compiles appropriately. |
Yes, the problem here is that "use" declarations are only valid in the local package. Since your interface has default methods, the ast gets copied to the package that declares the class. The compiler can't really point to a line in your file because they don't exist. We should make the error more explicit so that it says something like "the error is in a default method of an interface you're implementing". |
I believe this is #2150 although there could be a bit of FFI specific-ness. |
Yes, there will probably be some things to iron out if we import FFI declarations into other package, but we can probably tackle that after fixing #2150 |
I can build a quick minimal example - no problem. I'll also test locally. |
It was not successful:
I'm uploading this minimal case for you now for testing. |
See attached: |
There's two solutions to this problem.
This is somewhat complicated by the fact that technically, we only allow one declaration of a given FFI function per-package. So, how do we deal with that? Do we say, you can only declare once, but you can use different declarations that get pulled in from different packages?
Solution two is easier to maintain. It has less cognitive overhead for implementers and for the programmer, but it does require a bit more code and work from the developer per FFI method to call from the default method. I think the wrapping FFI calls in primitives is a generally good idea that I would favor advocating, but the more methods you are wrapping, the more arduous it becomes. @ponylang/committer any preference between solution 1 or 2. |
We decided during sync that #2 is the better option for a "pragmatic fix" for this. |
This is a weird one, an edge case - but I'm documenting it here as it may become relevant at some point.
When you have a class in DirectoryA use an Interface in DirectoryB, and the Interface in DirectoryB makes an FFI call, DirectoryA needs to have a copy of the FFI use declarations.
The compiler complaining is completely appropriate, the reason for documenting the issue is that the error message from the compiler gives no reference to the actual problem at all.
The compiler produced pages and pages of this:
The file itself looks like this:
Methinks this will likely be resolved by the RFC that's currently open.
The text was updated successfully, but these errors were encountered: