-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Remove delegates (RFC 31) #1534
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've missed some tests about delegates in parse_expr.cc
.
I've also left a comment on the source code.
In general it looks good and could be merged as is but I think it needs some more polishing to be considered a "true" removal of the feature.
// Order should be: | ||
// id type value delegate_type | ||
REORDER(0, 1, 3, 2); | ||
AST_NODE(TK_NONE); // provides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That node is unnecessary. I think we can completely remove that child node and refactor the parts of the compiler that try to access it, like we discussed in #1514.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the node and calls to it result in the SugarTest.ObjectWithField
test failing with the following message:
Error:
Unexpected child node found, flet
object let x: T = 3 fun foo() => 4 end
^
test/libponyc/util.cc:271: Failure
Value of: false
Actual: false
Expected: true
test/libponyc/util.cc:317: Failure
Expected: check_ast_same(expect_package, package) doesn't generate new fatal failures in the current thread.
Actual: it does.
test/libponyc/sugar.cc:1531: Failure
Expected: test_equiv(short_form, "sugar", full_form, "parse") doesn't generate new fatal failures in the current thread.
Actual: it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think removing the blank provides node added to fields by the object literal sugar will fix the problem. It's in pass/sugar.c
line 840.
@Praetonus The provides node has been removed from the field AST. |
|
||
case TK_EMBED: | ||
{ | ||
if(ast_childidx(ast, 3) == NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this isn't the right thing to do. With the change to the grammar, embed
nodes will always have 3 childs and this condition will always be true, which means we'll never check that an embedded field has a valid type.
We should always go through the checks and return AST_OK
instead of flatten_provides_list
at the end.
@@ -279,10 +279,12 @@ ast_result_t pass_flatten(ast_t** astp, pass_opt_t* options) | |||
|
|||
case TK_FVAR: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TK_FVAR
and TK_FLET
cases should be completely removed here, or else they'll go through the same checks as TK_EMBED
, which is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks!
This PR removes delegates as a language feature by removing the implementation and tests for delegates from the compiler.
Closes #1514