-
Notifications
You must be signed in to change notification settings - Fork 280
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 listing/mapping in iterables #752
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.
Sad, but true.
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.
Sorry, wasn't paying attention when I reviewed that. As discussed off-line; this surfacing another bug, I think close it out and have a go at tracking a marker in AstBuilder.
There is currently a bug around resolving variables within the iterable of a for generator or spread syntax (apple#741) Normally, mappings/listings are type-checked lazily. However, this results in the said bug getting widened, for any object members declared in the iterable. As a workaround for now, prevent the bug from being any worse by ensuring that these object members are eagerly typechecked.
f705df9
to
c2f7879
Compare
Okay, this is now using the AstBuilder approach. This works a lot better; take another look! |
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.
No blockers, but I'd profile a bit before adding a member to every object member.
createSourceSection(ctx), | ||
expr, | ||
ctx.QSPREAD() != null, | ||
symbolTable.getCurrentScope().isVisitingIterable()); |
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.
If this scope is not aligned with the above, something went wrong, no?
symbolTable.getCurrentScope().isVisitingIterable()); | |
visitingIterable); |
@@ -27,6 +27,9 @@ | |||
import org.pkl.core.util.Nullable; | |||
|
|||
public final class ObjectMember extends Member { | |||
|
|||
private final boolean isInIterable; |
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.
Seems costly... not worth rolling it into the member's modifiers
? Probably worth profiling (both jpkl
and native) on large corpora.
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.
Good idea! Will make this a modifier instead.
pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java
Outdated
Show resolved
Hide resolved
pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java
Outdated
Show resolved
Hide resolved
@@ -26,6 +26,7 @@ | |||
/** A property definition that has a type annotation. */ | |||
public final class TypedPropertyNode extends RegularMemberNode { | |||
@Child private DirectCallNode typeCheckCallNode; | |||
private final ObjectMember member; |
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.
If booleans can be tightly packed, the cost concern in ObjectMember
(above) goes away. In that case, I'd also just grab the single boolean here, because a pointer won't be.
@@ -35,9 +38,11 @@ public ObjectMember( | |||
SourceSection headerSection, | |||
int modifiers, | |||
@Nullable Identifier name, | |||
String qualifiedName) { | |||
String qualifiedName, | |||
boolean isInIterable) { |
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.
There's quite a lot of extra code throughout, all with a default false
case. I don't care much, considering it's likely rather temporary, but might it be worth an extra constructor that defaults this to false
?
Co-authored-by: Philip K.F. Hölzenspies <[email protected]>
1d03f34
to
3e00f3f
Compare
76007bb
to
aa38373
Compare
This mitigates an issue where lazy mappings and listings widen an existing bug. This is a follow-up to apple#752.
This mitigates an issue where lazy mappings and listings widen an existing bug. This is a follow-up to apple#752.
This mitigates an issue where lazy mappings and listings widen an existing bug. This is a follow-up to #752.
When we introduced lazy listing/mapping typechecking, we widened an existing bug around resolving for-generator variables in #741.
To prevent this bug from being widened, this introduces logic to eagerly evaluate any
Listing<V>
orMapping<K, V>
found in the iterable.We're not sure what the best approach is yet to fix the bug. In the meantime, this prevents the existing bug from being any more prevalent than it currently is.