racket / racket/typed-racket

Re-exported typed signature recognized as untyped signature

Open
#538 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
575
Forks
106
Avg merge
2h 1m
Merged PRs (30d)
2

Description

I'm not sure if this is a bug or just an intended behavior because there's no contract protecting signatures flowing from untyped to typed.

What version of Racket are you using?

v6.9.0.2

What program did you run?

File untyped-sig.rkt:

#lang racket
(provide sig^)
(define-signature sig^ (n))

File sig.rkt:

#lang typed/racket
(require/typed "untyped-sig.rkt"
  [#:signature sig^
   ([n : Number])])
(provide sig^)

File main.rkt:

#lang typed/racket

(require "sig.rkt")

(define-unit u@
  (import)
  (export sig^)
  (define n 42))
What should have happened?

Program ok

If you got an error message, please include it here.
; Error in macro expansion -- use of untyped signature in typed code;
;  consider using `require/typed' to import it
;   signature: sig^
;   in: (define-unit u@ (import) (export sig^) (define n 42))

If I copy the require/typed clause over, the program works as expected:

#lang typed/racket

(require/typed "sig.rkt"
  [#:signature sig^
   ([n : Number])])

(define-unit u@
  (import)
  (export sig^)
  (define n 42))

(define-values/invoke-unit/infer u@)
n ; ==> 42

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running main.rkt with the provided sig.rkt and untyped-sig.rkt files, then compare it with the working require/typed example. Trace how the re-exported sig^ is classified during define-unit macro expansion; done means the first program runs successfully without copying the require/typed clause.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.