typed/racket/gui : possible bug in slider%.get-value

Tim Brown <[email protected]>
Newsgroups gmane.comp.lang.racket.user,gmane.lisp.scheme.plt
Message-ID <[email protected]>
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.