I just got an interesting and very scary contract error. I tried to reproduce it, but I can’t quite do it. I think I can see (part of) what’s going on, though.
Suppose I have a file called bad1.rkt that is in Typed Racket (I’m guessing this is significant) and exports a structure called ClassInfo using struct-out, along with a constant, e.g. K1, with value “text.rkt”. I also have a file bad2.rkt that requires bad1, and exports a function called ‘gather-grades’ with contract (-> ClassInfo? boolean?) Finally, bad3.rkt requires both of the above, constructs a ClassInfo, and passes it to gather-grades. All good so far. Now, I made a very small change to bad1.rkt; specifically, I deleted a few characters from a regular expression. Then, I ran bad3.rkt. I then got a totally frightening contract error, that said (paraphrased from memory, sadly): Contract error: expected “text.rkt”, got #<ClassInfo> from contract on gather-grades, with contract (“text.rkt” -> boolean?) … In other words, the “ClassInfo?” predicate had mysteriously been replaced by one that checked for the value “text.rkt”, another value exported by the original TR module. I made a trivial change to bad2.rkt to force recompilation, and as expected, the error went away. I then spent 15 minutes trying to recreate the error, but all I’m getting now is this: link: bad variable linkage; reference to a variable that is uninitialized reference phase level: 0 variable module: (submod "/Users/clements/git-clements/clements/pkgs/jbc-utils/shelly/bad1.rkt" #%contract-defs) variable phase: 0 reference in module: "/Users/clements/git-clements/clements/pkgs/jbc-utils/shelly/bad2.rkt" in: idX10.94 > … which I’m guessing is the “correct” error, in that it’s telling me to recompile. Although… perhaps this is another manifestation of the same problem. I think the trigger here is that I’m using the exported function “ClassInfo?” as part of a 'contract-out’ form in bad2.rkt, and that this use isn’t properly forcing recompilation. Also, I initially assumed that TR had something to do with this, but I may be mistaken. Apologies for not copying the original error message before re-running… Let me know if this is enough information to submit a bug report. John Clements -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

