Re: typed/racket/gui : possible bug in slider%.get-value
Sam Tobin-Hochstadt <[email protected]>
| Newsgroups | gmane.comp.lang.racket.user,gmane.lisp.scheme.plt |
|---|---|
| Message-ID | <CAK=HD+YQiBGXTaQHcZJsOB1CgWmeaUerU6Kb3zdE7ZUknMF58A@mail.gmail.com> |
Thanks for noticing this! The type of `get-value` was wrong, probably due to reading `position-integer?` in the docs as `positive-integer?`, or something like that. I'll push a repair. Sam On Wed, Sep 7, 2016 at 7:47 AM, Tim Brown <[email protected]> wrote: > The following code produces a contract error; I think TR is making > assumptions that it probably shouldn’t be. > > Please could someone investigate. > > Thanks, > > Tim > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > #lang typed/racket/gui > (define f (new frame% [label "Frame"])) > (define sldr > (new slider% > [parent f] > [max-value 0] > [min-value -1] > [init-value 0] > [callback (λ (sldr cntrl-evnt) > (displayln (get-v)))] > [label (format "It's false if negative")])) > > (define (get-v) : (Option Index) > (define v (send sldr get-value)) > (printf "~s ~s ~s~%" v (negative? v) (if (negative? v) #f v)) > (if (negative? v) > #f > (cast v Index))) > > (send f show #t) > (send sldr set-value -1) > (get-v) > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > Runtime error is: > ---------------------------------------------------------------------- > broke its own contract > promised: Index > produced: -1 > in: Index > contract from: cast > blaming: cast > (assuming the contract is correct) > at: unsaved-editor:18.6 > ---------------------------------------------------------------------- > > -- > Tim Brown CEng MBCS <[email protected]> > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ > City Computing Limited · www.cityc.co.uk > City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB > T:+44 20 8770 2110 · F:+44 20 8770 2130 > ──────────────────────────────────────────────────────────────────────── > City Computing Limited registered in London No:1767817. > Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE > VAT No: GB 918 4680 96 > > -- > 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] > 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.