tizoc/shen-scheme

Exception in *unknown-location*: invalid syntax

diseraluca opened this issue · 3 comments

I was rewriting my test framework from scratch and laying some foundations for a new architecture I have in mind.

The current version of the file, with everything not related to the issue I was able to remove removed, and other parts simplified as much as I could, can be found at the end of this post.

Unfortunately, I wasn't able to discern where this is coming from to build a minimal reproducible example, I apologize for that.

I'm not hundred percent sure this is a bug, but the same code seems to work correctly on shen-cl.

The related part of the code has an entry-point in shennong.test-macro.
For this current version, this is intended to be used with a call similar to (shennong.shen Symbol (= Something SomethingElse)).

The expected behavior, which is executed on shen-cl, is that the expansion and call completes correctly, adding some data to shennong.*test-list* and shennong.*test-map*.

On shen-scheme, instead, the following error is given, at the end of the expansion of test-macro:

Exception in *unknown-location*: invalid syntax

For example, when the following REPL session is executed from the folder where the bug.shen file is located:

❯ rlwrap -c shen

Shen, copyright (C) 2010-2015 Mark Tarver
www.shenlanguage.org, Shen 22.2
running under Scheme, implementation: chez-scheme
port 0.24 ported by Bruno Deferrari


(load "bug.shen")
[]
#<hashtable>
shennong.quote
shennong.quote*
shennong.default-executor
shennong.default-reporter
shennong.default-handler
shennong.initial-state
shennong.apply-advice
shennong.apply-advices-to-unit
shennong.apply-advices
shennong.compile-definitions
shennong.register-test
shennong.test-macro

run time: 0.010132051000000003 secs
loaded

(shennong.test symbol (= 10 20))
Exception in *unknown-location*: invalid syntax

From the track reports, this seems to happen right after the output of test-macro, before register-test is to be called.

❯ rlwrap -c shen

Shen, copyright (C) 2010-2015 Mark Tarver
www.shenlanguage.org, Shen 22.2
running under Scheme, implementation: chez-scheme
port 0.24 ported by Bruno Deferrari


(load "bug.shen")
[]
#<hashtable>
shennong.quote
shennong.quote*
shennong.default-executor
shennong.default-reporter
shennong.default-handler
shennong.initial-state
shennong.apply-advice
shennong.apply-advices-to-unit
shennong.apply-advices
shennong.compile-definitions
shennong.register-test
shennong.test-macro

run time: 0.00971619 secs
loaded

(track shennong.register-test)
shennong.register-test

(track shennong.test-macro)
shennong.test-macro

(shennong.test symbol (= 10 20))

 <1> Inputs to shennong.test-macro 
 20,  ==>

 <1> Output from shennong.test-macro 
 ==> 20

 <1> Inputs to shennong.test-macro 
 10,  ==>

 <1> Output from shennong.test-macro 
 ==> 10

 <1> Inputs to shennong.test-macro 
 =,  ==>

 <1> Output from shennong.test-macro 
 ==> =

 <1> Inputs to shennong.test-macro 
 [= 10 20],  ==>

 <1> Output from shennong.test-macro 
 ==> [= 10 20]

 <1> Inputs to shennong.test-macro 
 symbol,  ==>

 <1> Output from shennong.test-macro 
 ==> symbol

 <1> Inputs to shennong.test-macro 
 shennong.test,  ==>

 <1> Output from shennong.test-macro 
 ==> shennong.test

 <1> Inputs to shennong.test-macro 
 [shennong.test symbol [= 10 20]],  ==>

 <1> Output from shennong.test-macro 
 ==> [shennong.register-test symbol [cons [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]] []]]

 <1> Inputs to shennong.test-macro 
 shennong.register-test,  ==>

 <1> Output from shennong.test-macro 
 ==> shennong.register-test

 <1> Inputs to shennong.test-macro 
 symbol,  ==>

 <1> Output from shennong.test-macro 
 ==> symbol

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 #<procedure>,  ==>

 <1> Output from shennong.test-macro 
 ==> #<procedure>

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 #<procedure>,  ==>

 <1> Output from shennong.test-macro 
 ==> #<procedure>

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 let,  ==>

 <1> Output from shennong.test-macro 
 ==> let

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 LeftResult,  ==>

 <1> Output from shennong.test-macro 
 ==> LeftResult

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 10,  ==>

 <1> Output from shennong.test-macro 
 ==> 10

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 RightResult,  ==>

 <1> Output from shennong.test-macro 
 ==> RightResult

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 20,  ==>

 <1> Output from shennong.test-macro 
 ==> 20

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 =,  ==>

 <1> Output from shennong.test-macro 
 ==> =

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 10,  ==>

 <1> Output from shennong.test-macro 
 ==> 10

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 20,  ==>

 <1> Output from shennong.test-macro 
 ==> 20

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [] []]

 <1> Inputs to shennong.test-macro 
 [cons 20 [cons [] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons 20 [cons [] []]]

 <1> Inputs to shennong.test-macro 
 [cons cons [cons 20 [cons [] []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons cons [cons 20 [cons [] []]]]

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [cons cons [cons 20 [cons [] []]]] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons cons [cons 20 [cons [] []]]] []]

 <1> Inputs to shennong.test-macro 
 [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]

 <1> Inputs to shennong.test-macro 
 [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]]

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]

 <1> Inputs to shennong.test-macro 
 [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]

 <1> Inputs to shennong.test-macro 
 [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]]

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 make-string,  ==>

 <1> Output from shennong.test-macro 
 ==> make-string

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 "Expected ~A But Found ~A",  ==>

 <1> Output from shennong.test-macro 
 ==> "Expected ~A But Found ~A"

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 LeftResult,  ==>

 <1> Output from shennong.test-macro 
 ==> LeftResult

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 RightResult,  ==>

 <1> Output from shennong.test-macro 
 ==> RightResult

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons RightResult []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons RightResult []]

 <1> Inputs to shennong.test-macro 
 [cons LeftResult [cons RightResult []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons LeftResult [cons RightResult []]]

 <1> Inputs to shennong.test-macro 
 [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]

 <1> Inputs to shennong.test-macro 
 [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]]

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 =,  ==>

 <1> Output from shennong.test-macro 
 ==> =

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 LeftResult,  ==>

 <1> Output from shennong.test-macro 
 ==> LeftResult

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 RightResult,  ==>

 <1> Output from shennong.test-macro 
 ==> RightResult

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons RightResult []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons RightResult []]

 <1> Inputs to shennong.test-macro 
 [cons LeftResult [cons RightResult []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons LeftResult [cons RightResult []]]

 <1> Inputs to shennong.test-macro 
 [cons = [cons LeftResult [cons RightResult []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons = [cons LeftResult [cons RightResult []]]]

 <1> Inputs to shennong.test-macro 
 cons,  ==>

 <1> Output from shennong.test-macro 
 ==> cons

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [] []]

 <1> Inputs to shennong.test-macro 
 [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]

 <1> Inputs to shennong.test-macro 
 [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]]

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]

 <1> Inputs to shennong.test-macro 
 [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]

 <1> Inputs to shennong.test-macro 
 [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]]

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]

 <1> Inputs to shennong.test-macro 
 [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]

 <1> Inputs to shennong.test-macro 
 [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]]

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]

 <1> Inputs to shennong.test-macro 
 [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]

 <1> Inputs to shennong.test-macro 
 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]

 <1> Inputs to shennong.test-macro 
 [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]

 <1> Inputs to shennong.test-macro 
 [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]

 <1> Inputs to shennong.test-macro 
 [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]]

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]

 <1> Inputs to shennong.test-macro 
 [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]

 <1> Inputs to shennong.test-macro 
 [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]]

 <1> Inputs to shennong.test-macro 
 [],  ==>

 <1> Output from shennong.test-macro 
 ==> []

 <1> Inputs to shennong.test-macro 
 [cons [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]] []],  ==>

 <1> Output from shennong.test-macro 
 ==> [cons [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]] []]

 <1> Inputs to shennong.test-macro 
 [shennong.register-test symbol [cons [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]] []]],  ==>

 <1> Output from shennong.test-macro 
 ==> [shennong.register-test symbol [cons [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]] []]]
Exception in *unknown-location*: invalid syntax

Copying and executing the output of this macro seems to work correctly (I've tried changing the two pretty-printed #<procedure> with (function shennong.default-handler/reporter) and it works the same too):

❯ rlwrap -c shen

Shen, copyright (C) 2010-2015 Mark Tarver
www.shenlanguage.org, Shen 22.2
running under Scheme, implementation: chez-scheme
port 0.24 ported by Bruno Deferrari


(load "bug.shen")
[]
#<hashtable>
shennong.quote
shennong.quote*
shennong.default-executor
shennong.default-reporter
shennong.default-handler
shennong.initial-state
shennong.apply-advice
shennong.apply-advices-to-unit
shennong.apply-advices
shennong.compile-definitions
shennong.register-test
shennong.test-macro

run time: 0.009931190000000006 secs
loaded

     (shennong.register-test symbol [cons [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]] []])
[cons [cons #<procedure> [cons #<procedure> [cons [cons let [cons LeftResult [cons 10 [cons RightResult [cons 20 [cons [cons cons [cons [cons cons [cons = [cons [cons cons [cons 10 [cons [cons cons [cons 20 [cons [] []]]] []]]] []]]] [cons [cons cons [cons [cons make-string [cons "Expected ~A But Found ~A" [cons LeftResult [cons RightResult []]]]] [cons [cons cons [cons [cons = [cons LeftResult [cons RightResult []]]] [cons [] []]]] []]]] []]]] []]]]]]] []]]] []]

(value shennong.*test-list*)
[symbol]

I'm not sure what the problem is. I don't doubt that it may be some error in what I'm doing and that it is shen-cl at fault for working, but I wasn't able to identify the problem and the code seems correct to me.

I apologize if this turns out to not be a bug.
Let me know if you need anything else or if there is something I can do to help.


Reduced bug file:

(package shennong []

(set *test-list* [])
(set *test-map* (shen.dict 1000))

(defmacro quote
  [quote [X | Y]] -> [cons [quote X] [quote Y]]
  [quote X] -> X)

(define quote*
  [] -> []
  [unquote* X] -> X
  [X | Y] -> [cons (quote* X) (quote* Y)]
  X -> X)

(define default-executor
  Artifact -> (eval Artifact))

(define default-reporter
  [Definition Failure true]  -> (output "~R : Success~%" Definition)
  [Definition Failure false] -> (output "~R : ~A~%" Definition Failure))

(define default-handler
  [[= Left Right] State] -> [[
                             (function default-executor) (function default-reporter)
                             [let (protect LeftResult)  Left
                                  (protect RightResult) Right
                                  (quote* [[= Left Right]
                                        [unquote*
                                         [make-string "Expected ~A But Found ~A" (protect LeftResult) (protect RightResult)]]
                                        [unquote* [= (protect LeftResult) (protect RightResult)]]])]]
                             | continue])

(define initial-state ->
  (let State (shen.dict 1000)
    (do (shen.dict-> State advices [(function default-handler)])
        (shen.dict-> State indentation 0)
        State)))

(define apply-advice
  [[Definition|Definitions] Artifacts State] Advice -> (let AdviceResult (Advice [Definition State])
                                                         [[Definitions (append Artifacts [(hd AdviceResult)]) State] | (tl AdviceResult)]))
(define apply-advices-to-unit
  TestUnit [] Command -> TestUnit
  TestUnit Advices stop -> TestUnit
  TestUnit [Advice|Advices] continue -> (let AdviceResult (apply-advice TestUnit Advice)
                                          (apply-advices-to-unit (hd AdviceResult) Advices (tl AdviceResult))))

(define apply-advices
  [[] Artifacts State] Advices -> [[] Artifacts State]
  TestUnit Advices -> (apply-advices (apply-advices-to-unit TestUnit Advices continue) Advices))

(define compile-definitions
  [[] Artifacts State] -> Artifacts
  [Definitions Artifacts State] -> (compile-definitions (apply-advices [Definitions Artifacts State] (shen.<-dict State advices))))

(define register-test
  Symbol Artifacts -> (do
                        (set *test-list* (adjoin Symbol (value *test-list*)))
                        (put Symbol tests Artifacts (value *test-map*))))

(defmacro test-macro
  [test Symbol | Definitions] ->
    [register-test Symbol
                  (quote* (compile-definitions [(quote Definitions) [] (initial-state)]))])

)
tizoc commented

Hello @diseraluca, I have to look at it more in depth latter, but from a quick read it is very likely that the issue is related to those #<procedure> you see there. You are producing a list that is then evaluated right? It should not contain procedure objects in there, because procedures are not valid s-expressions:

Chez Scheme Version 9.5.4
Copyright 1984-2020 Cisco Systems, Inc.

> (eval (lambda (x) x))
Exception: invalid syntax #<procedure>
Type (debug) to enter the debugger.

it works with SBCL because it doesn't seem to mind:

This is SBCL 2.0.11, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (eval (lambda (x) x))
#<FUNCTION (LAMBDA (X)) {529E827B}>

You should produce instead some named functions and refer them by name in your expanded code, or produce some code to obtain the procedure you created (I see you store some stuff with put, so you probably need to generate something like [get some-symbol tests [value *test-map*]].

Hi @tizoc,

Thank you so much for taking the time to look at this.

My shame as this is similar to a problem I resolved on the previous versions of this and that you already explained to me on the shen group.

Thank you again for looking at this and for your clear explanation.

I'm closing this as it is not related to shen-scheme directly.

tizoc commented

You are welcome!