-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
Default trait methods do not have access to imports from their declaring file. #2150
Comments
Yeah, we've experienced this at Sendence. You need the import in the file where it gets used which... isn't right but it's a temporary work around. You nicely found a minimal case for us. |
So, this is an interesting one. We need the type resolution that happens in the Not sure off the top of my head what the best approach for a fix is, but that's the problem in brief. |
I did hit the same one. Just out of curiosity, would this also fail if the |
@mfelsche yes, you would have the same problem. |
Properties do not need to import everything property.pony needed because of this ponyc bug: ponylang/ponyc#2150 anymore, due to the great work on #32
As raised today on Zulip, this bug also happens with interfaces. |
I think the best way to fix this would be to split off the part of the This is how I solved a similar issue in the Mare compiler. |
I looked at refer.c and nothing jump out as "the part of the refer pass that deals with type names". What did you mean? |
ast_result_t pass_names(ast_t** astp, pass_opt_t* options) also handle TK_REFERENCE. If lowercase name, don't touch.
come into names. |
I'm working on this with some assistance from @jemc. |
I have a fix for this. I need to clean it up as its two bunches of identical code copied into two locations, I'll have a PR open sometime this week. FYI the notes above for how to address aren't the path I ended up using as I ran into issues with the original idea. |
…m default method bodies (#4027) We've had issues with symbols within trait and interface default method bodies. If symbols used within those bodies were not available in the local scope that the method bodies were added to, the symbols couldn't be found. The issue was that we were only searching the local scope. This change adds an additional AST symbol lookup strategy where we look for a function or behavior as our parent. If one exists, we check to see if it was provided by a trait. This is done by looking to see if the AST data is present. If it is, then that is the AST for original trait implementation of the method. We can then use that AST node to find symbols that were present at the original declaration site of the trait. Fixes #3737 Fixes #2150
If I have the following files:
I get the following error message:
If I add
use "debug"
to the top ofbar.pony
, the error goes away. I assume that traits' default methods' AST gets copied to where they are instantiated, but then they lose access to the imports from their original file.The text was updated successfully, but these errors were encountered: