Opened 6 years ago

Last modified 13 months ago

#1513 assigned defect

Type declarations in modules do not namespace structs

Reported by: sjamaan Owned by:
Priority: major Milestone: someday
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 (14)

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

comment:4 Changed 6 years ago by evhan

Owner: set to evhan
Status: newassigned

Patch posted.

comment:5 Changed 6 years ago by sjamaan

Version: 5.05.0.0rc1

comment:6 Changed 6 years ago by sjamaan

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

comment:7 Changed 6 years ago by sjamaan

Milestone: 5.05.1

Moving to 5.1 for a proper fix

comment:8 Changed 6 years ago by evhan

Owner: evhan deleted

comment:9 Changed 6 years ago by sjamaan

Version: 5.0.0rc15.0.0

comment:10 Changed 6 years ago by sjamaan

Version: 5.0.05.0

comment:11 Changed 6 years ago by sjamaan

Milestone: 5.15.2

comment:12 Changed 5 years ago by felix winkelmann

Milestone: 5.25.3

comment:13 Changed 3 years ago by sjamaan

Milestone: 5.35.4

comment:14 Changed 13 months ago by felix winkelmann

Milestone: 5.4someday
Note: See TracTickets for help on using tickets.