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

coverage testing broken for some uses of vector-set! #1315

Open
jbclements opened this issue Mar 3, 2023 · 1 comment
Open

coverage testing broken for some uses of vector-set! #1315

jbclements opened this issue Mar 3, 2023 · 1 comment

Comments

@jbclements
Copy link
Contributor

What version of Racket are you using?

8.8.0.8--2023-02-23(-/f) [cs].

What program did you run?

#lang typed/racket

(: my-vector-set! (All (T) ((Vectorof T) Natural T -> Void)))
(define (my-vector-set! vec idx newval)
  (vector-set! vec idx newval))

(define v (vector 1 2 3))

(vector-set! v 0 1234)
(my-vector-set! v 0 1234)
(vector-set! v (ann 0 Natural) 1234)

What should have happened?

The program should have shown complete coverage.

If you got an error message, please include it here.

Instead, the first use of vector-set! is shown as not having coverage. Running the macro expander indicates that this use of vector-set! is expanded into a conditional which calls the native vector-set! only if the vector is immutable, and an unsafe version otherwise. I conjecture that fixing this is a matter of ensuring that the application of the unsafe vector mutator is given the source location of the original application. It looks like this might be on or near line 87 of vector.rkt, but I see a conspicuous lack of similar source location annotations in this code, so perhaps this is actually a larger problem.

Either way, there are workarounds (albeit cryptic ones), as this snippet demonstrates.

@jbclements
Copy link
Contributor Author

Bump, a new generation of students are running into this...

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

1 participant