Skip to content
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

Inconsistent gvector-set! Behavior under Type-based-casts vs. Coercions #115

Open
Temurson opened this issue Apr 15, 2021 · 1 comment
Open

Comments

@Temurson
Copy link
Contributor

I was trying to come up with an example where erasing casts could lead to value representation issues, and accidentally found what seems to be a bug:

(let ([vec : (GVect Dyn) (gvector 1 #f)])
  (begin (print-int 7)
         (gvector-set! vec 0 42)
         (print-int 9)))

When compiling with --type-based-casts, this code compiles successfully, and prints 7, but never prints 9, and doesn't print any errors. On the other hand, when compiling with --coercions, this prints "7Implicit cast in binding on expression at example.grift:1:25" (which is the cast from (GVect Bool) to (GVect Dyn)).
First, this is clearly inconsistent behavior. Second, I am not sure why when using the coercion representation of casts, this even gives a cast error. Since the vector is parameterized by Dyn, shouldn't we be able to assign anything to it?
I saw other issues where type-based casts exhibit inconsistent behavior. I would be interested in fixing these inconsistencies, although I would like some guidance on what parts of code I should look at. This clearly happens after reduce-to-cast-calculus step, but I'm unsure where to look next.

@akuhlens
Copy link
Collaborator

akuhlens commented Apr 16, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants