-
Notifications
You must be signed in to change notification settings - Fork 284
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
Eagerly check function arguments when called from inside iterable #778
Conversation
This mitigates an issue where lazy mappings and listings widen an existing bug. This is a follow-up to apple#752.
* <p>If {@code value} is conforming, sets {@code slot} to {@code value}. Otherwise, throws a | ||
* {@link VmTypeMismatchException}. | ||
*/ | ||
public abstract Object executeEagerlyAndSet(VirtualFrame frame, Object value); |
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.
This method is used when checking a function's arguments.
This node:
function foo(bar: Listing<Int>) =
^^^^^^^^^^^^
We need to add the method because we need to capture the logic of:
- Run an eager typecheck
- Set that value on the frame.
f9e2984
to
a23b8f8
Compare
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.
Sad but necessary, I guess :(
@@ -36,6 +36,7 @@ | |||
import org.pkl.core.runtime.VmFunction; | |||
|
|||
/** A virtual method call. */ | |||
@SuppressWarnings("DuplicatedCode") |
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.
What does this overlap with?
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 various specializations here. Adding just one more line to each method triggered the duplicate code detection warning.
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. We can improve it once we have parse time variables.
@@ -44,7 +44,7 @@ public final class FunctionNode extends RegularMemberNode { | |||
// For VmObject receivers, the owner is the same as or an ancestor of the receiver. | |||
// For other receivers, the owner is the prototype of the receiver's class. | |||
// The chain of enclosing owners forms a function/property's lexical scope. | |||
private static final int IMPLICIT_PARAM_COUNT = 2; | |||
private static final int IMPLICIT_PARAM_COUNT = 3; |
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.
We should update the docs which still state there are "two implicit arguments".
This mitigates an issue where lazy mappings and listings widen an existing bug.
This is a follow-up to #752.
Ideally, when we fix the scoping bug, we also revert this commit.