Skip to content

Cross-module require/typed not working with #:struct #:extra-constructor-name #1507

@cloudrac3r

Description

@cloudrac3r
#lang typed/racket/base

;; ----- 1 -----
#;(require/typed/provide web-server/http/request-structs
    [#:struct header ([field : Bytes] [value : Bytes]) #:extra-constructor-name make-header])

;; ----- 2 -----
#;#;(module inner typed/racket/base
  (require/typed/provide web-server/http/request-structs
    [#:struct header ([field : Bytes] [value : Bytes]) #:extra-constructor-name make-header]))
(require 'inner)

;; ----- 3 -----
#;#;(module inner typed/racket/base
  (require/typed/provide web-server/http/request-structs
    [#:struct header ([field : Bytes] [value : Bytes])]))
(require 'inner)

;; ----- check -----
(header #"user-agent" #"b")

Uncomment each of 1, 2, or 3 in turn and try it.

1 is just the standard situation. It imports the struct. It works. All is well.

2 is require/typed/provide from an inner module, which is in turn required by the main module. In theory this should be equivalent, but it actually doesn't work:

; header.rkt:20:0: header: identifier for static struct-type information cannot be used as an expression
;   in: (header #"user-agent" #"b")

The same error occurs when attempting to use the built-in typed/web-server/http module, which uses the same code. This makes HTTP headers unusable from Typed Racket.

I think it is a bug that this does not work.

3 is the same as 1 but I have removed #:extra-constructor-name. This also works, which indicates that the problem may have something to do with #:extra-constructor-name. Maybe that's helpful for you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions