Discussion:
[Larceny-users] Syntax violations need &syntax
Derick Eddington
2009-03-18 23:01:07 UTC
Permalink
Per R6RS 5.5 "Syntax violations", the below exceptions must have a
condition with type &syntax. (And probably shouldn't have &error
because of what R6RS says it's for.)

(The below is in ERR5RS mode, but the same issue seems to be happening
in R6RS mode, and I'm guessing ERR5RS mode wants to conform to R6RS in
this matter.)

Larceny v0.97a4 (alpha test) (Mar 18 2009 10:48:46, precise:Linux:unified)
larceny.heap, built on Wed Mar 18 10:50:45 PDT 2009
ERR5RS mode (no libraries have been imported)
(import
(rnrs)
(rnrs eval)
(xitomatl records))
Autoloading (rnrs)
Autoloading (rnrs eval)
Autoloading (xitomatl records)
Autoloading (rnrs enums)
Autoloading (rnrs lists)
Autoloading (rnrs syntax-case)
Autoloading (rnrs conditions)
Autoloading (err5rs records procedural)
Autoloading (rnrs exceptions)
Autoloading (rnrs hashtables)
Autoloading (rnrs arithmetic bitwise)
Autoloading (rnrs programs)
Autoloading (rnrs files)
Autoloading (rnrs io ports)
Autoloading (larceny deprecated)
Autoloading (rnrs records syntactic)
Autoloading (rnrs records procedural)
Autoloading (rnrs control)
Autoloading (rnrs sorting)
Autoloading (rnrs bytevectors)
Autoloading (rnrs unicode)
(define-syntax show-ex
(syntax-rules ()
((_ expr)
(show-ex expr '(rnrs)))
((_ expr env ...)
(guard (ex (else
(map (lambda (c)
(list c (map (lambda (a) (a c))
(record-type-accessors (record-rtd c)))))
(simple-conditions ex))))
(eval '(let () expr)
(environment env ...))))))
(show-ex (lambda ((oops)) 1))
Syntax violation: lambda

Invalid form

Form: (lambda ((oops)) 1)

Trace:

(lambda ((oops)) 1)

(lambda () (lambda ((oops)) 1))

((lambda () (lambda ((oops)) 1)))

((#<record &error> ())
(#<record &who> (syntax-violation))
(#<record &message> ("lambda: Invalid form"))
(#<record &irritants> (((lambda ((oops)) 1)))))
(show-ex (define ((oops)) 1))
Syntax violation: define

Invalid form

Form: (define ((oops)) 1)

Trace:

(lambda () (define ((oops)) 1))

((lambda () (define ((oops)) 1)))

((#<record &error> ())
(#<record &who> (syntax-violation))
(#<record &message> ("define: Invalid form"))
(#<record &irritants> (((define ((oops)) 1)))))
I didn't check other forms, and I'm guessing they need to be updated
also.

My need for this to conform is I have macros which rely on the forms
they expand to to detect syntax violations of some parts of my macros'
input, and my test programs (and fantasies of ultra meta programming)
need misuses of my macros to raise &syntax exceptions.
--
: Derick
----------------------------------------------------------------
Derick Eddington
2009-03-18 23:04:23 UTC
Permalink
Post by Derick Eddington
Per R6RS 5.5 "Syntax violations", the below exceptions must have a
condition with type &syntax.
(library (L) (export x) (import (rnrs)) (define x 1))
(show-ex (set! L:x 'oops)
'(rnrs base)
'(prefix (L) L:))

Syntax violation: set!

Directly or indirectly imported variable cannot be assigned

Subform: L:x

Form: (set! L:x 'oops)

Trace:

(set! L:x 'oops)

(lambda () (set! L:x 'oops))

((lambda () (set! L:x 'oops)))

((#<record &error> ())
(#<record &who> (syntax-violation))
(#<record &message>
("set!: Directly or indirectly imported variable cannot be assigned"))
(#<record &irritants> (((set! L:x 'oops) L:x))))
Post by Derick Eddington
(call-with-output-file "/tmp/L.sls"
(lambda (fop)
(put-datum fop
'(library (L)
(export (oops))
(import (rnrs))
(define oops 1)))))
Post by Derick Eddington
(show-ex (load "/tmp/L.sls")
'(rnrs base)
'(err5rs load))

Syntax violation: export

Invalid export set

Form: (oops)

Trace:

((#<record &error> ())
(#<record &who> (syntax-violation))
(#<record &message>
("export: Invalid export set"))
(#<record &irritants> (((oops)))))
--
: Derick
----------------------------------------------------------------
Derick Eddington
2009-03-18 23:26:45 UTC
Permalink
Post by Derick Eddington
Per R6RS 5.5 "Syntax violations", the below exceptions must have a
condition with type &syntax.
(show-ex (let-syntax ((sc (lambda (stx)
(syntax-case stx ()
((_ x) #'x)))))
(sc)))

Syntax violation: sc

Invalid form

Form: (sc)

Trace:

(sc)

(lambda ()
(let-syntax
((sc (lambda (stx) (syntax-case stx () ((_ x) #'x)))))
(sc)))

((lambda ()
(let-syntax
((sc (lambda (stx) (syntax-case stx () ((_ x) #'x)))))
(sc))))

((#<record &error> ())
(#<record &who> (syntax-violation))
(#<record &message> ("sc: Invalid form"))
(#<record &irritants> (((sc)))))
--
: Derick
----------------------------------------------------------------
William D Clinger
2009-03-19 04:44:53 UTC
Permalink
Logged as ticket #622. Fixed by changeset:6150.

Thanks!

Will

Continue reading on narkive:
Loading...