[plt-scheme] Typechecking command-line

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Tue Mar 17 20:44:09 EDT 2009

Hi,

Trying to typecheck a file containing a call to command line fails.
Here's a short version exemplifying the issue:
#lang typed-scheme

(require scheme/cmdline)

(: version-str String)
(define version-str "0.1")

(current-command-line-arguments (vector "counter.mch"))

(: verbose-mode (Parameter Boolean))
(define verbose-mode (make-parameter #f))

(: optimize-level (Parameter Integer))
(define optimize-level (make-parameter 0))

(: model-checking-mode (Parameter (U 'sat)))
(define model-checking-mode (make-parameter 'sat))

(: file-to-model-check String)
(define file-to-model-check
  (command-line
   #:program "eboc" ;; Should be name of executable
   #:once-each
   [("-v" "--verbose") "Compile with verbose messages"
                       (verbose-mode #t)]
   [("-m" "--mode") mode "Mode to run the model checker on (sat, satbin)"
                    (model-checking-mode mode)]
   #:once-any
   [("-o" "--optimize-1") "Compile with optimization level 1"
                          (optimize-level 1)]
   ["--optimize-2"        (; show help on separate lines
                           "Compile with optimization level 2,"
                           "which includes all of level 1")
                          (optimize-level 2)]

   #:args (filename) ; expect one command-line argument: <filename>
   ; return the argument as a filename to compile
   filename))


Error is:

typecheck: Error in macro expansion -- untyped var: flag in: (define
file-to-model-check (command-line #:program "eboc" #:once-each (("-v"
"--verbose") "Compile with verbose messages" (verbose-mode #t)) (("-m"
"--mode") mode "Mode to run the model checker on (sat, satbin)"
(model-checking-mode mode)) #:once-any (("-o" "--optimize-1") "Compile
with optimization level 1" (optimize-level 1)) ("--optimize-2"
("Compile with optimization level 2," "which includes all of level 1")
(optimize-level 2)) #:args (filename) filename))

Since it mentions a 'flag' variable and no flag variable exists in my
file, I guess this is something to do with command-line expansion?

Cheers,
-- 
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm


Posted on the users mailing list.