-
Notifications
You must be signed in to change notification settings - Fork 122
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
A compiler error on Unification.hs
when accessing the field
#1022
Comments
This is certainly a bug, I'll look into it. |
A quick question that is not really related to this issue: Why does an expression like |
This is #197 |
Fixes a bug in lazy constraint expansion. When performing type inference for a field access expression (`x.f`), we generate a lazy constraint with an branch per each struct type that has a field named `n`. We expand the constraint as soon as we know the name of the struct, at which point we can prune all incorrect options. However, the code incorrectly assumed that the field type is also fully concretized at this point, which is generally not true, as type arguments may still be unknown types. The fix doesn't attempt to concretize the field completely, but instead simply substitutes what we know about type arguments at this point. Fixes vmware#1022. Signed-off-by: Leonid Ryzhyk <[email protected]>
@qishen, I believe I fixed the bug in my fork. I will submit a PR with the fix shortly, I just want to also add your linked list example as a test, but haven't had a chance to go through it yet. Do you happen to have some code/data to test your implementation? |
@ryzhyk Sorry I haven't tested my implementation yet and just use the linked list in a few places assuming the implementation is correct. I can help to write some tests on the linked list if you want. |
Comments regarding list implementation:
Looks ok otherwise, but also kind of shows that ddlog is not the best language for implementing these data structures right now. A native implementation in Rust would probably work better (and would enable double-linked lists as well). |
|
This seems to work:
|
A better implementation of
|
Fixes a bug in lazy constraint expansion. When performing type inference for a field access expression (`x.f`), we generate a lazy constraint with an branch per each struct type that has a field named `n`. We expand the constraint as soon as we know the name of the struct, at which point we can prune all incorrect options. However, the code incorrectly assumed that the field type is also fully concretized at this point, which is generally not true, as type arguments may still be unknown types. The fix doesn't attempt to concretize the field completely, but instead simply substitutes what we know about type arguments at this point. Fixes vmware#1022. Signed-off-by: Leonid Ryzhyk <[email protected]>
Linked list example based on @qishen's code. Signed-off-by: Leonid Ryzhyk <[email protected]>
Linked list example based on @qishen's code. Signed-off-by: Leonid Ryzhyk <[email protected]>
Linked list example based on @qishen's code. Signed-off-by: Leonid Ryzhyk <[email protected]>
Thanks and I just found the same issues when testing it on some real data. |
Fixes a bug in lazy constraint expansion. When performing type inference for a field access expression (`x.f`), we generate a lazy constraint with an branch per each struct type that has a field named `n`. We expand the constraint as soon as we know the name of the struct, at which point we can prune all incorrect options. However, the code incorrectly assumed that the field type is also fully concretized at this point, which is generally not true, as type arguments may still be unknown types. The fix doesn't attempt to concretize the field completely, but instead simply substitutes what we know about type arguments at this point. Fixes #1022. Signed-off-by: Leonid Ryzhyk <[email protected]>
Linked list example based on @qishen's code. Signed-off-by: Leonid Ryzhyk <[email protected]>
I got a compiler error if I uncomment
var node = reversed_list.node
in the functionnonnull_list_nth()
to access the field. I don't quite understand the error message:ddlog: Unification.teToType: non-constant type expression 'a50 CallStack (from HasCallStack): error, called at src/Language/DifferentialDatalog/Unification.hs:415:35 in differential-datalog-0.42.0-1PgGWEVSzEkJuq6cM15JM0:Language.DifferentialDatalog.Unification
. Hope I find another bug to improve ddlog or let me know the right way to write the function in my linked list implementation. Thanks!Below is a quick implementation of linked list in DDLog that probably has the worst performance on list operations because of tons of
deref()
and ugly workarounds but I'm using this linked list implementation somewhere that does not require high performance or even incrementality. I appreciate any suggestion to enhance it even though you may not want it to be included in the standard library.The text was updated successfully, but these errors were encountered: