Racket - cannot send prefab struct through place channel when there's a contract on it

Viewed 61

I'm having an issue where I can't send a prefab struct across a place channel if the struct was imported with a contract. Here's a complete example:

#lang racket

(module structs racket

  (provide
   example-without-contract
   (contract-out [struct example-with-contract ([thing string?])]))

  (struct example-without-contract (thing) #:prefab)
  (struct example-with-contract (thing) #:prefab))

(require 'structs)
(displayln (format "Can send example-without-contract: ~A"
                   (place-message-allowed? (example-without-contract "abc"))))
(displayln (format "Can send example-with-contract: ~A"
                   (place-message-allowed? (example-with-contract "abc"))))

With Racket 6.8, this prints:

Can send example-without-contract: #t
Can send example-with-contract: #f

There's nothing in the documentation that mentions contracts. Is this an actual limitation, and if so, is there any way to work around it? (Short of just creating another struct to send through the channel, I guess).

1 Answers
Related