Thanks Matthew, that's fascinating. So do you think I was encountering it
due to something like background expansion and a test submodule with quoted
reference cases in my checks or something else? Maybe having that file open
while also working on a file that requires it? I looked over the source
file and don't see any kind of case like your example, but my test
submodule definitely includes such examples (the whole point of using
prefabs for me is the read behavior).

Deren

On Thu, Jun 22, 2017 at 12:22 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> This is a bug in prefab registration when an instance of the prefab is
> loaded via `read` before the `struct` declaration is encountered.
>
> In other words, putting
>
>  '#s((indexable (2 #f)) 0 #f)
>
> at the *start* of the first module below and running in a fresh Racket
> or DrRacket will demonstrate the problem. Running in a fresh Racket
> avoids any cached structure type for the prefab.
>
> The problem is specific to prefab struct types that include an auto
> field.
>
> I'll push a repair. Thanks for the report!
>
> At Thu, 22 Jun 2017 10:38:36 -0400, Deren Dohoda wrote:
> > Hi Racketeers,
> >
> > I am having some frustrations dealing with mutable prefab structures,
> > getting errors about attempting to mutate an immutable structure. I wish
> I
> > could give you a sequence of simple steps that I know for sure would
> > reproduce the problem but I have not found them. I thought I had one
> > yesterday, but then on a whim I blasted my racket installation and
> > reinstalled. This seemed to work. Today I go back to my files and my
> tests,
> > which have previously passed, are failing. This is extremely confusing
> > because in fact I have actually used this module already successfully
> > without any problems. I thought it was some module+ problem or rackunit
> > issue causing test failures but it is definitely not related to that as I
> > have it happen in other files entirely.
> >
> > Again I truly apologize for not having a more complete means of
> reproducing
> > the problem, but here is what I have right now. I am not even sure if you
> > follow my steps you can reproduce it.
> >
> > Launch DrRacket. Open the file "mutable-test.rkt", code below, failure
> for
> > no obvious reason:
> >
> > #lang racket/base
> > (struct indexable ((id #:auto)
> >                    (date #:auto))
> >   #:mutable
> >   #:prefab)
> >
> > (define indexed (indexable))
> > (set-indexable-id! indexed 0)
> > indexed
> > ;;;; ERROR
> > set-indexable-id!: cannot modify value of immutable field in structure
> >   structure: '#s((indexable (2 #f)) #f #f)
> >   field index: 0
> >
> > ;;;;;;;;;;;;;
> >
> > In file "mutable-test-2.rkt", success:
> >
> > #lang racket/base
> > (struct id ((index #:auto) (date #:auto)) #:mutable #:prefab)
> >
> > (for/list ((i (in-range 5)))
> >   (let ((I (id)))
> >     (set-id-index! I i)
> >     I))
> >
> > (struct derived id (val) #:prefab)
> >
> > (for/list ((i (in-range 5)))
> >   (let ((D (derived i)))
> >     (set-id-index! D i)
> >     D));;;;;;;;;;;;;;;;
> >
> > Weird, right? Is the "indexable" name a problem? If I change the name by
> > just adding an "e" it works:
> >
> > #lang racket/base
> > (struct indexablee ((id #:auto)
> >                    (date #:auto))
> >   #:mutable
> >   #:prefab)
> >
> > (define indexed (indexablee))
> > (set-indexablee-id! indexed 0)
> > indexed
> > ;;;;;;;;
> >
> > Now I go back to "mutable-test.rkt" and simply change the structure
> > definition to remove the "date" field as so:
> > (struct indexable ((id #:auto))
> >   #:mutable
> >   #:prefab)
> >
> > and this also works.
> >
> > Any ideas?
> >
> > Thanks,
> > Deren
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to