From 4db57816fc1d4931fd01a2f261746923b01704f3 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 17 Nov 2013 16:32:04 -0600 Subject: [PATCH] Guard drag-ok? so it handles the empty list properly change suggested by Stefan Schmiedl; closes PR 14164 It seems a bit strange that a region callback can be invoked when there are no cards, but looking at the card library it isn't obvious that the list is supposed to be non-empty, so probably better to just be "defensive" in this case, rather than attempting to tighten the contracts --- pkgs/games/spider/spider.rkt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/games/spider/spider.rkt b/pkgs/games/spider/spider.rkt index 21cccc939c..3af63d0330 100644 --- a/pkgs/games/spider/spider.rkt +++ b/pkgs/games/spider/spider.rkt @@ -195,12 +195,13 @@ #f))) (define (drag-ok? cards i) - (let ([c (car cards)] - [l (vector-ref stacks i)]) - (and l - (or (null? l) - (= (send (car l) get-value) - (add1 (send c get-value))))))) + (and (pair? cards) + (let ([c (car cards)] + [l (vector-ref stacks i)]) + (and l + (or (null? l) + (= (send (car l) get-value) + (add1 (send c get-value)))))))) (let loop ([i 0]) (unless (= i (vector-length stacks))