default   Racket Bugs
Main PageQuick QueryStandard QueryAdvanced QueryHelp
Log in

View Problem Report: 12503

send email to interested parties or send email followup to audit-trail
Reporter's email: danburton dot email at gmail dot com
Number: 12503
Category: contract
Synopsis: Extending Typed Racket struct in (untyped) Racket
Class: sw-bug
Responsible: samth
Notify-List:
Severity: serious
Priority: medium
State: open
Confidential: no
Arrival-Date: Fri Jan 20 18:56:01 -0500 2012
Closed-Date:
Last-Modified: Tue Apr 30 08:00:02 -0400 2013
Originator: Dan Burton
Organization: plt
Submitter-Id: unknown
Release: 5.1.3
Environment: linux-ubuntu
Description: When providing a struct defined in typed racket:

structures-test.rkt
#lang typed/racket
(define-struct foo ())
(provide (struct-out foo))

And trying to extend that struct in untyped racket:

reader-test.rkt
#lang racket
(require "structures-test.rkt")
(define-struct (bar foo) ())

We encounter the following error:
Type Checker: The type of struct:foo cannot be converted to a contract in: struct:foo3
File Attachments:
How-To-Repeat:
Fix:
Release-Note:
Unformatted:

send email to interested parties or send email followup to audit-trail

Audit Trail:

From: Eric Dobson <eric.n.dobson at gmail.com>
To: samth at racket-lang.org, stamourv at racket-lang.org, bugs at racket-lang.org,
        danburton.email at gmail.com
Cc: 
Subject: Re: typed-scheme/12503: Extending Typed Racket struct in (untyped) Racket
Date: Mon, 29 Apr 2013 21:16:27 -0700

 The issue with this is that if we allow this to type check then, a
 program like this is possible:
 
 #lang racket/load
 
 (module t typed/racket/base
   (struct: foo ((v : Integer)) #:transparent)
   (provide (struct-out foo)))
 
 (module user racket/base
   (require 't)
   (define-struct (bar foo) () #:transparent)
   (foo-v (bar 'x))
   )
 
 
 (require 'user)
 
 Which blames the typed module.
 
 We would need support for contracting structure type descriptors
 before TR can do anything about this.
From: Dan Burton <danburton.email at gmail.com>
To: Eric Dobson <eric.n.dobson at gmail.com>
Cc: samth at racket-lang.org, stamourv at racket-lang.org, bugs at racket-lang.org
Subject: Re: typed-scheme/12503: Extending Typed Racket struct in (untyped) Racket
Date: Tue, 30 Apr 2013 00:05:51 -0700

 --f46d04182724e3bd2804db8ea24f
 Content-Type: text/plain; charset=ISO-8859-1
 
 To clarify: the ideal behavior for that code is for the "bar" constructor
 to report a type error and blame the user for applying an 'x where it
 expected an Integer?
 
 -- Dan Burton
 
 
 On Mon, Apr 29, 2013 at 9:16 PM, Eric Dobson <eric.n.dobson at gmail.com>wrote:
 
 > The issue with this is that if we allow this to type check then, a
 > program like this is possible:
 >
 > #lang racket/load
 >
 > (module t typed/racket/base
 >   (struct: foo ((v : Integer)) #:transparent)
 >   (provide (struct-out foo)))
 >
 > (module user racket/base
 >   (require 't)
 >   (define-struct (bar foo) () #:transparent)
 >   (foo-v (bar 'x))
 >   )
 >
 >
 > (require 'user)
 >
 > Which blames the typed module.
 >
 > We would need support for contracting structure type descriptors
 > before TR can do anything about this.
 >
 
 --f46d04182724e3bd2804db8ea24f
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 <div dir=3D"ltr">To clarify: the ideal behavior for that code is for the &q=
 uot;bar&quot; constructor to report a type error and blame the user for app=
 lying an &#39;x where it expected an Integer?</div><div class=3D"gmail_extr=
 a">
 
 <br clear=3D"all"><div>-- Dan Burton</div>
 <br><br><div class=3D"gmail_quote">On Mon, Apr 29, 2013 at 9:16 PM, Eric Do=
 bson <span dir=3D"ltr">&lt;<a href=3D"mailto:eric.n.dobson at gmail.com" targe=
 t=3D"_blank">eric.n.dobson at gmail.com</a>&gt;</span> wrote:<br><blockquote c=
 lass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
 padding-left:1ex">
 
 The issue with this is that if we allow this to type check then, a<br>
 program like this is possible:<br>
 <br>
 #lang racket/load<br>
 <br>
 (module t typed/racket/base<br>
 =A0 (struct: foo ((v : Integer)) #:transparent)<br>
 =A0 (provide (struct-out foo)))<br>
 <br>
 (module user racket/base<br>
 =A0 (require &#39;t)<br>
 =A0 (define-struct (bar foo) () #:transparent)<br>
 =A0 (foo-v (bar &#39;x))<br>
 =A0 )<br>
 <br>
 <br>
 (require &#39;user)<br>
 <br>
 Which blames the typed module.<br>
 <br>
 We would need support for contracting structure type descriptors<br>
 before TR can do anything about this.<br>
 </blockquote></div><br></div>
 
 --f46d04182724e3bd2804db8ea24f--
From: Sam Tobin-Hochstadt <samth at ccs.neu.edu>
To: Dan Burton <danburton.email at gmail.com>
Cc: Eric Dobson <eric.n.dobson at gmail.com>, stamourv <stamourv at racket-lang.org>,
        bugs <bugs at racket-lang.org>
Subject: Re: typed-scheme/12503: Extending Typed Racket struct in (untyped) Racket
Date: Tue, 30 Apr 2013 07:59:23 -0400

 On Tue, Apr 30, 2013 at 3:05 AM, Dan Burton <danburton.email at gmail.com> wrote:
 > To clarify: the ideal behavior for that code is for the "bar" constructor to
 > report a type error and blame the user for applying an 'x where it expected
 > an Integer?
 
 Yes, exactly.
 
 Sam
 
 >
 > -- Dan Burton
 >
 >
 > On Mon, Apr 29, 2013 at 9:16 PM, Eric Dobson <eric.n.dobson at gmail.com>
 > wrote:
 >>
 >> The issue with this is that if we allow this to type check then, a
 >> program like this is possible:
 >>
 >> #lang racket/load
 >>
 >> (module t typed/racket/base
 >>   (struct: foo ((v : Integer)) #:transparent)
 >>   (provide (struct-out foo)))
 >>
 >> (module user racket/base
 >>   (require 't)
 >>   (define-struct (bar foo) () #:transparent)
 >>   (foo-v (bar 'x))
 >>   )
 >>
 >>
 >> (require 'user)
 >>
 >> Which blames the typed module.
 >>
 >> We would need support for contracting structure type descriptors
 >> before TR can do anything about this.
 >
 >