Summary

Type declarations in modules do not namespace structs

Metadata

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

[2018-09-01 00:09:16 UTC] evhan removed owner evhan

[2018-11-09 15:18:46 UTC] sjamaan changed version from 5.0.0rc1 to 5.0.0

[2018-11-09 15:20:50 UTC] sjamaan changed version from 5.0.0 to 5.0

[2019-04-08 12:48:43 UTC] sjamaan changed milestone from 5.1 to 5.2

[2019-08-25 17:31:31 UTC] felix changed milestone from 5.2 to 5.3

[2021-06-16 10:43:06 UTC] sjamaan changed milestone from 5.3 to 5.4

[2023-11-06 22:05:49 UTC] felix changed milestone from 5.4 to someday