plt/racket — pull request #139 by shekari (2012-08-24 07:10:02+00:00)
Title: Fix type->contract on structures. Now uses struct/c.

This is still not complete. It fails on one test case, fail/pr11686.rkt.

The issue is that the constraint on what kind of contract we need to produce can come from multiple places.
For a immutable struct contract we need that each field is a chaperone contract. Any type which contains an Univ type on the typed side will produce a impersonator contract due to any-wrap. The issue is when we need to make a recursive contract for a Mu type. We need to make it a impersonator contract if it contains an Univ, and we need to make it a chaperone contract if a struct type uses its recursive id in a chaperone only context.

My current solution is to just assume that structs won't use the contract recursively, which is why it fails the test case. The correct solution is to see if it is used in any place where it needs to be a chaperone and then make it a chaperone, otherwise make it an impersonator.

On a side note, I don't see what any-wrap/c protects against. Why cannot it be any/c?