Skip to content

Subtyping structs from untyped code is unsound #815

Open
@lexi-lambda

Description

@lexi-lambda

This program segfaults:

#lang racket

(module untyped racket
  (provide (struct-out foo))
  (struct foo (value)))

(module typed typed/racket
  (require/typed
   (submod ".." untyped)
   [#:struct foo ([value : (-> (List Integer) Integer)])])
  (provide the-bar)
  (struct bar foo ())
  (define the-bar (bar (λ (lst) (car lst)))))

(require 'untyped
         'typed)

((foo-value the-bar) #f)

The the-bar export appears to escape with an any/c contract, since TR believes it has proved the relevant obligations, but as the program demonstrates, that just isn’t true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions