[racket] struct contract violation problem

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Oct 23 18:31:21 EDT 2013

Here are two ideas.

1) You simply have an old use of the original net/url. When #<url> is
printed, it uses the symbolic name and you can't really figure out
what the underlying code came from. I would do a grep to make sure
this is not the case.

2) You are using namespaces somewhere and actually have two instances
of the same module somewhere where a value produced by copy 1 is going
to copy 2. This is possible with the Web server if you don't set up
the servlet namespace properly:

http://docs.racket-lang.org/web-server-internal/dispatch-servlets.html#(part._namespace)

On Wed, Oct 23, 2013 at 4:25 PM, Erik Pearson <erik at adaptations.com> wrote:
> Excuse my poor experience with contracts, this is probably an easy one.
>
> I'm using a copy of net/url and have a strange problem. The copied library
> is working fine in general, but this problem cropped up today:
>
> struct:exn:fail:contract:blame url-port: contract violation
> expected: url?
> given: #<url>
> in: the 1st argument of
> (-> url? (or/c #f number?))
> contract from:
> /home/epearson/work/racket/github/adaptnet/url-structs.rkt
> blaming: /home/epearson/work/racket/github/racqueb/httpc.rkt
> at: /home/epearson/work/racket/github/adaptnet/url-structs.rkt:4.28
>
> The error is thrown in my usage of url-port which is being passed a
> perfectly good url struct object. The file is requiring the copied
> url-structs. If I play with the function that is being blamed in httpc.rkt
> via the repl in dr racket, this specific error is not thrown. The call to
> (url-port url) succeeds without throwing this contract exception.
>
> From my primitive understanding, I'm flummoxed: Why is a #<url> not a url?
>
> I suspected that there may have been a leftover require of net/url confusing
> things, but I can't find any in my code.
>
> Using racket head from github 5.90.0.9--2013-10-20(d6610289/d)
>
> Help!
>
> Thanks,
> Erik.
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.