Opened 4 weeks ago

Last modified 3 weeks ago

#1513 assigned defect

Type declarations in modules do not namespace structs

Reported by: sjamaan Owned by:
Priority: major Milestone: 5.1
Component: core libraries Version: 5.0.0rc1
Keywords: Cc:
Estimated difficulty: easy


As reported by Jörg Wittenberger, the following program gives a compilation warning in CHICKEN 5 but not in CHICKEN 4:

 (import scheme)
   (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.

Change History (8)

comment:1 Changed 4 weeks ago by megane

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.

comment:2 Changed 4 weeks ago by megane

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.

comment:3 Changed 4 weeks ago by evhan

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).

Last edited 4 weeks ago by evhan (previous) (diff)

comment:4 Changed 4 weeks ago by evhan

  • Owner set to evhan
  • Status changed from new to assigned

Patch posted.

comment:5 Changed 4 weeks ago by sjamaan

  • Version changed from 5.0 to 5.0.0rc1

comment:6 Changed 4 weeks ago by sjamaan

Fixed with a workaround, for the time being, in 55bb90510bea0bb7618193f2797e30f2207a41b7.

comment:7 Changed 4 weeks ago by sjamaan

  • Milestone changed from 5.0 to 5.1

Moving to 5.1 for a proper fix

comment:8 Changed 3 weeks ago by evhan

  • Owner evhan deleted
Note: See TracTickets for help on using tickets.