typed-racket
typed-racket copied to clipboard
Some problems related to `quasiquote`.
What version of Racket are you using?
v8.4 [cs]
What program did you run?
In untyped version:
Welcome to Racket v8.4 [cs].
> (define a '(x y z))
> (define b 'b)
> `(,@a . ,b)
'(x y z . b)
>
In typed version:
Welcome to Racket v8.4 [cs].
> (define a '(x y z))
> (define b 'b)
> `(,@a . ,b)
string:1:4: Type Checker: type mismatch
expected: (Listof a)
given: (List 'x 'y 'z)
in: a
[,bt for context]
> ,bt
string:1:4: Type Checker: type mismatch
expected: (Listof a)
given: (List 'x 'y 'z)
in: a
location...:
string:1:4
context...:
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/check-below.rkt:62:0: check-below
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt:32:0: tc/funapp1
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt:183:0: domain-mismatches
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-funapp.rkt:71:0: tc/funapp
.../private/runtime.rkt:80:24: temp667
.../private/runtime.rkt:89:23: fail-handler110
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:112:0: tc-expr/check
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:694:0: tc-toplevel-form
.../private/runtime.rkt:80:24: temp25
/usr/share/racket/pkgs/xrepl-lib/xrepl/xrepl.rkt:1573:0
/usr/share/racket/collects/racket/repl.rkt:11:26
>
And in some cases, the error message will prompt that it is related to qq-append:
#lang typed/racket/base
(define-type S-Exp (U Symbol Null (Pair S-Exp S-Exp)))
(define-predicate s-exp? S-Exp)
(: a (Listof Symbol))
(define a '(x y z))
(: b (U Null Symbol))
(define b 'b)
(ann `(,@a . ,b) S-Exp)
What should have happened?
'(x y z . b)
If you got an error message, please include it here.
draft.rkt:12:5: Type Checker: Polymorphic function `qq-append' could not be applied to arguments:
Types: (Listof a) (Listof b) -> (Listof (U a b))
Arguments: (Listof Symbol) (U Null Symbol)
Expected result: S-Exp
in: (quasiquote ((unquote-splicing a) unquote b))
location...:
draft2.rkt:12:5
context...:
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:455:0: type-check
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:682:0: tc-module
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:101:12
/usr/share/racket/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:22:4