[racket-dev] #f instead of path-string? when (require cKanren)

From: A.J. Lepper (angus.lepper at gmail.com)
Date: Thu Oct 2 12:05:51 EDT 2014

Windows 64-bit, Racket v6.1 64-bit

If I install cKanren from the package manager then (require cKanren) works
fine in Racket.exe from the command prompt, but produces an error in
DrRacket. simple-form-path receives #f instead of a path-string?, from
file-stamp-in-paths. Adding a [(false? (car paths)) #f] clause to the outer
cond stops the error, but may not be a good fix - I got a bit lost digging
through the stack above it and went for the easy option. I've attached the
backtrace.

Thanks very much,
-Angus.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20141002/10c3b948/attachment.html>
-------------- next part --------------
simple-form-path: contract violation
  expected: path-string?
  given: #f

C:\Program Files\Racket\collects\racket\path.rkt: 14:0   (define (simple-form-path p)
  (unless (path-string? p)
    (raise-argument-error 'simple-form-path "path-string?" p))
  (simplify-path (path->complete-path p)))

C:\Program Files\Racket\collects\compiler\cm.rkt: 51:4       (let c-loop ([paths paths])
      (cond
        [(null? paths) #f]
        ;;[(false? (car paths)) #f]
        [else
         (let i-loop ([collects-eles (explode-path (simple-form-path (car paths)))]
                      [p-eles p-eles])
           (cond
             [(null? collects-eles)
              ;; we're inside the collection hierarchy, so we just 
              ;; use the date of the original file (or the zo, whichever
              ;; is newer).
              (let-values ([(base name dir) (split-path p)])
                (let* ([p-date (file-or-directory-modify-seconds p #f (lambda () #f))]
                       [alt-date (and (not p-date)
                                      (file-or-directory-modify-seconds 
                                       (rkt->ss p) 
                                       #f 
                                       (lambda () #f)))]
                       [date (or p-date alt-date)]
                       [get-path (lambda ()
                                   (if p-date
                                       p
                                       (rkt->ss p)))]
                       [modes (use-compiled-file-paths)]
                       [roots (current-compiled-file-roots)]
                       [get-zo-date+mode (lambda (name)
                                           (ormap
                                            (lambda (root)
                                              (ormap
                                               (lambda (mode)
                                                 (let ([v (file-or-directory-modify-seconds
                                                           (build-path 
                                                            (reroot-path* base root)
                                                            mode
                                                            (path-add-suffix name #".zo"))
                                                           #f
                                                           (lambda () #f))])
                                                   (and v (list* v mode root))))
                                               modes))
                                            roots))]
                       [main-zo-date+mode (and (or p-date (not alt-date))
                                               (get-zo-date+mode name))]
                       [alt-zo-date+mode (and (or alt-date
                                                  (and (not p-date) 
                                                       (not alt-date)
                                                       (not main-zo-date+mode)))
                                              (get-zo-date+mode (rkt->ss name)))]
                       [zo-date+mode (or main-zo-date+mode alt-zo-date+mode)]
                       [zo-date (and zo-date+mode (car zo-date+mode))]
                       [get-zo-path (lambda ()
                                      (let-values ([(name mode root)
                                                    (if main-zo-date+mode
                                                        (values (path-add-suffix name #".zo")
                                                                (cadr main-zo-date+mode)
                                                                (cddr main-zo-date+mode))
                                                        (values (path-add-suffix (rkt->ss name) #".zo")
                                                                (cadr alt-zo-date+mode)
                                                                (cddr alt-zo-date+mode)))])
                                        (build-path (reroot-path* base root) mode name)))])
                  (cond
                   [(and zo-date
                         (or (not date)
                             (zo-date . > . date)))
                    (cons zo-date
                          (delay (get-compiled-file-sha1 (get-zo-path))))]
                   [date
                    (cons date
                          (delay (get-source-sha1 (get-path))))]
                   [else #f])))]
             [(null? p-eles) 
              ;; this case shouldn't happen... I think.
              (c-loop (cdr paths))]
             [else
              (cond
                [(equal? (car p-eles) (car collects-eles))
                 (i-loop (cdr collects-eles) (cdr p-eles))]
                [else 
                 (c-loop (cdr paths))])]))]))))

C:\Program Files\Racket\share\pkgs\drracket\drracket\private\eval-helpers.rkt: 127:9            (lambda (path mod-name)
           (if (and (member extra-compiled-file-path (use-compiled-file-paths))
                    (skip-path? path))
               (parameterize ([use-compiled-file-paths
                               (remove extra-compiled-file-path 
                                       (use-compiled-file-paths))])
                 (orig path mod-name))
               (orig path mod-name))))))

C:\Program Files\Racket\share\pkgs\drracket\drracket\private\rep.rkt: 1123:24                           (let loop ()
                          (define sexp/syntax/eof (with-stack-checkpoint (get-sexp/syntax/eof)))
                          (cond
                            [(eof-object? sexp/syntax/eof) (abort-current-continuation 
                                                            (default-continuation-prompt-tag)
                                                            (λ () (values)))]
                            [else
                             (define results
                               (call-with-values
                                (λ ()
                                  (parameterize ([do-dance #t])
                                    (eval-syntax sexp/syntax/eof)))
                                list))
                             (parameterize ([pretty-print-columns pretty-print-width])
                               (for ([x (in-list results)])
                                 ((current-print) x)))
                             (loop)])))))

C:\Program Files\Racket\collects\racket\private\more-scheme.rkt: 147:2     (define (call-with-break-parameterization paramz thunk)
    (unless (break-paramz? paramz)
      (raise-argument-error 'call-with-break-parameterization "break-parameterization?" 0 paramz thunk))
    (unless (and (procedure? thunk)
		 (procedure-arity-includes? thunk 0))
      (raise-argument-error 'call-with-parameterization "(-> any)" 1 paramz thunk))
    (begin0
     (with-continuation-mark
	 break-enabled-key
	 (break-paramz-ref paramz 0)
       (begin
	 (check-for-break)
	 (thunk)))
     (check-for-break)))

C:\Program Files\Racket\share\pkgs\drracket\drracket\private\rep.rkt: 1097:9            (λ () ; =User=, =Handler=, =No-Breaks=
           (let* ([settings (current-language-settings)]
                  [lang (drracket:language-configuration:language-settings-language settings)]
                  [settings (drracket:language-configuration:language-settings-settings settings)]
                  [dummy-value (box #f)]
                  [get-sexp/syntax/eof 
                   (if complete-program?
                       (send lang front-end/complete-program port settings)
                       (send lang front-end/interaction port settings))])
             
             ; Evaluate the user's expression. We're careful to turn on
             ;   breaks as we go in and turn them off as we go out.
             ;   (Actually, we adjust breaks however the user wanted it.)
             
             
             ;; this binding of last-results is to catch the results 
             ;; that come from throwing to the prompt instead of
             ;; a normal exit
             (define last-results
               (call-with-values
                (λ ()
                  (call-with-continuation-prompt
                   (λ ()
                     (call-with-break-parameterization
                      user-break-parameterization
                      (λ ()
                        (let loop ()
                          (define sexp/syntax/eof (with-stack-checkpoint (get-sexp/syntax/eof)))
                          (cond
                            [(eof-object? sexp/syntax/eof) (abort-current-continuation 
                                                            (default-continuation-prompt-tag)
                                                            (λ () (values)))]
                            [else
                             (define results
                               (call-with-values
                                (λ ()
                                  (parameterize ([do-dance #t])
                                    (eval-syntax sexp/syntax/eof)))
                                list))
                             (parameterize ([pretty-print-columns pretty-print-width])
                               (for ([x (in-list results)])
                                 ((current-print) x)))
                             (loop)])))))
                   (default-continuation-prompt-tag)
                   (letrec ([me
                             (λ args
                               (cond
                                 [(and (pair? args)
                                       (null? (cdr args))
                                       (procedure? (car args))
                                       (procedure-arity-includes? (car args) 0))
                                  (call-with-continuation-prompt (car args) 
                                                                 (default-continuation-prompt-tag)
                                                                 me)]
                                 [else
                                  (call-with-continuation-prompt
                                   (λ ()
                                     (call-with-continuation-prompt
                                      (λ ()
                                        (apply
                                         abort-current-continuation 
                                         (default-continuation-prompt-tag)
                                         args)))))]))])
                     me)))
                list))
             (parameterize ([pretty-print-columns pretty-print-width])
               (for ([x (in-list last-results)])
                 ((current-print) x)))
             
             (when complete-program?
               (call-with-continuation-prompt
                (λ ()
                  (call-with-break-parameterization
                   user-break-parameterization
                   (λ ()
                     (send lang front-end/finished-complete-program settings))))
                (default-continuation-prompt-tag)
                (λ args (void))))
             
             (when the-after-expression 
               (call-with-continuation-prompt
                (λ () 
                  (the-after-expression))))
             
             (set! in-evaluation? #f)
             (update-running #f)
             (cleanup)
             (flush-output (get-value-port))
             (queue-system-callback/sync
              (get-user-thread)
              (λ () ; =Kernel=, =Handler= 
                (after-many-evals)
                (cleanup-interaction)
                (insert-prompt)))))))

C:\Program Files\Racket\share\pkgs\drracket\drracket\private\rep.rkt: 1415:17                    (let loop () ; =User=, =Handler=, =No-Breaks=
                   ; Wait for something to do
                   (unless (semaphore-try-wait? eval-thread-queue-sema)
                     ; User event callbacks run here; we turn on
                     ;  breaks in the dispatch handler.
                     (yield eval-thread-queue-sema))
                   ; About to eval something
                   (semaphore-wait eval-thread-state-sema)
                   (let ([thunk (car eval-thread-thunks)])
                     (set! eval-thread-thunks (cdr eval-thread-thunks))
                     (semaphore-post eval-thread-state-sema)
                     ; This thunk evals the user's expressions with appropriate
                     ;   protections.
                     (thunk))
                   (loop)))))

C:\Program Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt: 451:6         (lambda ()
        ;; communicate the thunk to `really-dispatch-event':
        (define before (current-inexact-milliseconds))
        (when (log-level? event-logger 'debug)
          (log-message event-logger 'debug 
                       (format "starting to handle an event from ~a" (object-name thunk))
                       (gui-event before #f (object-name thunk))))
        (let ([b (box thunk)])
          ;; use the event-dispatch handler:
          (with-continuation-mark dispatch-event-key b
            ((event-dispatch-handler) e))
          ;; if the event-dispatch handler doesn't chain
          ;; to the original one, then do so now:
          (when (unbox b)
            (set-box! b #f)
            (thunk)))
        (define after (current-inexact-milliseconds))
        (when (log-level? event-logger 'debug)
          (log-message event-logger 'debug 
                       (format "handled an event: ~a msec"  
                               (- after before))
                       (gui-event before after (object-name thunk)))))

C:\Program Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt: 502:32                                   (lambda (v)
                                  (when v (handle-event v e))
                                  (yield evt))))

C:\Program Files\Racket\collects\racket\private\more-scheme.rkt: 147:2     (define (call-with-break-parameterization paramz thunk)
    (unless (break-paramz? paramz)
      (raise-argument-error 'call-with-break-parameterization "break-parameterization?" 0 paramz thunk))
    (unless (and (procedure? thunk)
		 (procedure-arity-includes? thunk 0))
      (raise-argument-error 'call-with-parameterization "(-> any)" 1 paramz thunk))
    (begin0
     (with-continuation-mark
	 break-enabled-key
	 (break-paramz-ref paramz 0)
       (begin
	 (check-for-break)
	 (thunk)))
     (check-for-break)))

C:\Program Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt: 397:18                     (let loop ()
                    (call-with-continuation-prompt
                     (lambda ()
                       ;; re-enable breaks (if they are supposed to be enabled):
                       (call-with-break-parameterization
                        break-paramz
                        (lambda () 
                          ;; yield; any abort (including a break exception)
                          ;; will get caught and the loop will yield again
                          (yield (make-semaphore))))))
                    (loop)))))))


Posted on the dev mailing list.