Opened 13 months 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.3
Component: core libraries Version: 5.0.0
Keywords: Cc:
Estimated difficulty: easy

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.

Change History (12)

comment:1 Changed 13 months 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 13 months 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 13 months 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 13 months ago by evhan (previous) (diff)

comment:4 Changed 13 months ago by evhan

Owner: set to evhan
Status: newassigned

Patch posted.

comment:5 Changed 13 months ago by sjamaan

Version: 5.05.0.0rc1

comment:6 Changed 13 months ago by sjamaan

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

comment:7 Changed 13 months ago by sjamaan

Milestone: 5.05.1

Moving to 5.1 for a proper fix

comment:8 Changed 13 months ago by evhan

Owner: evhan deleted

comment:9 Changed 10 months ago by sjamaan

Version: 5.0.0rc15.0.0

comment:10 Changed 10 months ago by sjamaan

Version: 5.0.05.0

comment:11 Changed 5 months ago by sjamaan

Milestone: 5.15.2

comment:12 Changed 3 weeks ago by felix winkelmann

Milestone: 5.25.3
Note: See TracTickets for help on using tickets.