racket / typed-racket

Typed Racket
Other
513 stars 102 forks source link

TR: untyped struct's parent can't be a typed struct #102

Open ntoronto opened 9 years ago

ntoronto commented 9 years ago
Originally submitted on: Wed Dec 31 22:44:01 -0500 2014

The error is

.../racket/collects/racket/contract/private/blame.rkt:143:0: struct:foo: contract violation
  Attempted to use a struct type reflectively in untyped code: #<struct-type:foo>
  in: "struct-type/c"
  contract from: (anonymous-module typed-defs)
  blaming: (anonymous-module untyped-defs)
   (assuming the contract is correct)
  at: unsaved-editor:5.10

This can make it difficult to convert a library to Typed Racket one piece at a time.

Steps to Reproduce:
#lang racket

(module typed-defs typed/racket
  (provide (all-defined-out))
  (struct foo () #:transparent))

(module untyped-defs racket
  (require racket/contract
           (submod ".." typed-defs))
  (provide (contract-out
            (struct bar ())))
  (struct bar foo () #:transparent))

(require 'untyped-defs)
(bar)
Release:
6.1.1.6--2014-12-21(-/f)
Environment:
unix "Linux snoopy 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64
 x86_64 x86_64 GNU/Linux" (x86_64-linux/3m) (get-display-depth) = 32
Human Language: english
(current-memory-use) 749009788
raco pkg (show):
Installation-wide:
 Package                 Checksum           Source
 disassemble             cf0ee3a5...        catalog...ssemble
 drbayes                                    link...il/drbayes
 main-distribution       67868e03...        catalog...ibution
 main-distribution-test  ca4a870e...        catalog...on-test
 nonplussed              f6c06999...        url.../nonplussed
 optimization-coach      be5f7908...        catalog...n-coach
 pict3d                                     link...eil/pict3d
 plot                    e536986e...        clone...path=plot
 racket-lib                                 static-link...lib
 rsound                  4f5d4d15...        catalog rsound
 slideshow-latex         9275fecb...        catalog...w-latex
 [214 auto-installed packages not shown]
User-specific for installation "development":
 [none]

Collections:
("/home/neil/.racket/development/collects"
 (non-existent-path))
("/home/neil/plt-fresh/racket/collects"
 (".gitignore" "acks" "compiler" "data" "db" "dynext" "ffi" "file" "info" "info-domain"
 "json" "launcher" "net" "openssl" "pkg" "planet" "racket" "raco" "reader" "realm" "s-exp"
 "setup" "syntax" "unstable" "version" "xml"))

Recent Internal Errors: 
Computer Language: (("Determine language from source") (#(#t print mixed-fraction-e #f #t
 none) (default) #() "#lang racket\n" #t #f ((test) (main)) #t))
This bug was converted from Gnats bug 14913.
bennn commented 9 years ago

Just ran into this same issue (on 6.2.0.2, porting a project from typed to untyped). The error message was very confusing to me.