[racket] [r6rs] mangling of condition object fields in eval

From: Marco Maggi (marco.maggi-ipsu at poste.it)
Date: Tue Apr 5 14:29:13 EDT 2011

The following program run with "plt-r6rs":

#!r6rs
(import (rnrs))
(guard (E (else
	   (write (condition-message E))(newline)
	   (write (syntax-violation-form E))(newline)
	   (write (syntax-violation-subform E))(newline)
	   #t))
  (syntax-violation 'doit "the message" #'(display) #'display))

prints:

"the message"
#<syntax:/home/marco/var/tmp/proof.sps:11:42 (display)>
#<syntax:/home/marco/var/tmp/proof.sps:11:54 display>

which is good; but the following program:

#!r6rs
(import (rnrs)
  (rnrs eval))

(guard (E (else
	   (write (condition-message E))(newline)
	   (write (syntax-violation-form E))(newline)
	   (write (syntax-violation-subform E))(newline)
	   #t))
  (eval '(let ()
	   (define-syntax doit
	     (lambda (stx)
	       (syntax-case stx ()
		 ((?id)
		  (syntax-violation 'doit "the message" stx (syntax->datum #'?id))))))
	   (doit))
	(environment '(rnrs))))

prints:

"doit: the message at: doit in: (doit)"
#<syntax doit>
#f

that  is:  the  message   is  changed,  the  form  field  is
overwritten with the subform field, the subform field is set
to #f, the  (sub)form field is converted to  a syntax object
(it was a sexpr when given to SYNTAX-VIOLATION).

  This is annoying  for me, because I rely  on the fields in
my test  suite to validate  reaction to syntax  errors.  Can
the correct  behaviour be enforced in  the implementation of
EVAL?

TIA
-- 
Marco Maggi


Posted on the users mailing list.