(Struct st) does not work with polymorphic structs
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 575
- Forks
- 106
- Avg merge
- 2h 1m
- Merged PRs (30d)
- 2
Description
What version of Racket are you using?
6.7.0.1
What program did you run?
#lang typed/racket
(struct (A) s1 ([f : A]))
(struct (A B) s2 s1 ([g : B]))
(struct s3 ([h : Symbol]))
(ann ((inst s2 Number String) 1 "b") (Struct s1)) ;; Error
(ann ((inst s2 Number String) 1 "b") (Struct s2)) ;; Error
(ann ((inst s2 Number String) 1 "b") (Struct (s1 Number))) ;; Works
(ann ((inst s2 Number String) 1 "b") (Struct (s2 Number String))) ;; Works
(ann (s3 'x) (Struct s3)) ;; Works
What should have happened?
The docs explicitly state that:
(Struct st)is a type which is a supertype of all instances of the potentially-polymorphic structure typest. Note that structure accessors forstwill not accept(Struct st)as an argument.
so the first two cases should work, but they throw an error instead.
If you got an error message, please include it here.
Type Checker: parse error in type;
expected a structure type for argument to Struct
given: s1 in: (Struct s1)
and
Type Checker: parse error in type;
expected a structure type for argument to Struct
given: s2 in: (Struct s2)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Typed Racket program in the issue and compare the two failing (Struct s1) and (Struct s2) annotations with the working parameterized forms. Done means the unparameterized polymorphic structure annotations are accepted as documented, while the existing working examples continue to pass.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100