The program consists of two polymorphic functions with identical bodies that return the argument after asserting that it is a pair with pair?. The functions are typed on homogeneous and heterogeneous lists, respectively (ttest-homo and ttest-hetero, respectively). Neither function should produce an error when passed a non-empty list.
However, ttest-hetero fails the pair? assertion when passed '(1 2 3) despite print debugging suggesting that the check should succeed. In contrast, its twin ttest-homo correctly returns without erroring.
The program typechecks successfully.
EmEf on Racket Discourse suggested stepping through the TR macros, revealing a problematic expansion of the predicate in the unless block to always return #f in ttest-hetero:
The (if (begin ... (quote #f)) ... ...) always goes to its else branch, leading to the error. ttest-homo does not add the extra (quote #f) to the predicate and thus behaves normally.
If you got an error message, please include it here.
error: wat (lol)
If I replace the (unless ...) with(assert lst pair?), the error is Assertion #<procedure:pair?> failed on '(1 2 3)
Related to (or maybe the same as?) to #412
What version of Racket are you using?
v8.14 [cs]
What program did you run?
What should have happened?
The program consists of two polymorphic functions with identical bodies that return the argument after asserting that it is a pair with
pair?
. The functions are typed on homogeneous and heterogeneous lists, respectively (ttest-homo
andttest-hetero
, respectively). Neither function should produce an error when passed a non-empty list.However,
ttest-hetero
fails thepair?
assertion when passed'(1 2 3)
despite print debugging suggesting that the check should succeed. In contrast, its twinttest-homo
correctly returns without erroring.The program typechecks successfully.
EmEf on Racket Discourse suggested stepping through the TR macros, revealing a problematic expansion of the predicate in the
unless
block to always return#f
inttest-hetero
:The
(if (begin ... (quote #f)) ... ...)
always goes to its else branch, leading to the error.ttest-homo
does not add the extra(quote #f)
to the predicate and thus behaves normally.If you got an error message, please include it here.
error: wat
(lol)If I replace the
(unless ...)
with(assert lst pair?)
, the error isAssertion #<procedure:pair?> failed on '(1 2 3)