Summary
Type declarations in modules do not namespace structs
Metadata
- Id: 68238b47f6d98df6def71b66fbdde8bcfc099c81
- Trac id: 1513
- Type: defect
- Reporter: sjamaan
- Owner:
- Cc:
- Status: new
- Component: core libraries
- Estimated difficulty: easy
- Resolution:
- Priority: major
- Milestone: someday
- Version: 5.0.0
- Changetime: 2023-11-06 22:05:49 UTC
- Created: 2018-08-20 21:49:00 UTC
- Keywords:
Description
As reported by Jörg Wittenberger, the following program gives a compilation warning in CHICKEN 5 but not in CHICKEN 4:
(module
foo
*
(import scheme)
(cond-expand
(chicken-5
(import
(chicken base)
(chicken type)
))
(else (import chicken)))
(: make-foo (string --> (struct foo)))
(define-record foo bar)
)
Presumably this is because the low-level name of the struct is `foo#foo` here (because we're inside a module). I think the correct fix for this would be to look at struct identifiers, and when unqualified, just prefix it.
Changes and comments
[2018-08-21 07:15:42 UTC] megane wrote:
Say, you're writing a module that uses struct `sfoo` from module `foo` and struct `sbar` from module `bar`. Then you define a function `foobar` and annotate it with type `((struct foo) (struct bar) -> *)`. I'm pretty sure we don't currently have the information to correctly qualify the struct names in this type.
[2018-08-21 07:26:30 UTC] megane wrote:
I think making just making unqualified struct identifiers proper supertypes of qualified identifiers would work. So saying `foo` is `((struct foo) -> *)` is saying `foo` can take any struct foo, from any module.
[2018-08-23 07:40:15 UTC] evhan wrote:
The best thing to do for 5.0 is probably just to strip namespaces from the ##sys#make-structure specialisation.
We can revisit and hopefully improve on this in 5.1 (or later).
[2018-08-23 07:40:15 UTC] evhan wrote:
1535006207317935
[2018-08-23 07:40:15 UTC] evhan wrote:
1535006219168654
[2018-08-23 23:52:28 UTC] evhan changed status from new to assigned
[2018-08-23 23:52:28 UTC] evhan set owner to evhan
[2018-08-23 23:52:28 UTC] evhan wrote:
Patch posted.
[2018-08-24 18:39:54 UTC] sjamaan changed version from 5.0 to 5.0.0rc1
[2018-08-24 18:44:38 UTC] sjamaan wrote:
Fixed with a workaround, for the time being, in 55bb90510bea0bb7618193f2797e30f2207a41b7.
[2018-08-24 21:06:57 UTC] sjamaan changed milestone from 5.0 to 5.1
[2018-08-24 21:06:57 UTC] sjamaan wrote:
Moving to 5.1 for a proper fix