New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R6RS eval allows assignments to imported primitives #697

Closed
WillClinger opened this Issue Jan 27, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@WillClinger
Member

WillClinger commented Jan 27, 2015

The eval procedure defined by (rnrs eval) correctly forbids all definitions, and forbids assignments to things defined by an R6RS library, but allows assignments to things imported using a (primitives ...) import spec.

This behavior is undocumented, so it can't be counted as a feature rather than a bug.

Example:

% larceny --err5rs
Larceny v0.97 "Funny in the Head" (Aug 19 2009 04:24:46, precise:Posix:unified)
larceny.heap, built on Wed Aug 19 04:26:48 EDT 2009
ERR5RS mode (no libraries have been imported)

> (import (rnrs base) (rnrs eval))
Autoloading (rnrs eval)

> (define env (environment '(rnrs base) '(larceny compiler)))
Autoloading (larceny compiler)

> (eval '(define x 19) env)
Autoloading (err5rs load)
Autoloading (rnrs load)

Syntax violation: define
Invalid form in expression sequence
Form: (define x 19)
Trace: 
Error: unhandled condition:
Compound condition has these components: 
#<record &who>
    who : define
#<record &message>
    message : "Invalid form in expression sequence"
#<record &syntax>
    form : (define x 19)
    subform : #f

Entering debugger; type "?" for help.
debug> q

> (eval '(set! x 19) env)

Syntax violation: invalid reference
No binding available for x in library (anonymous)
Form: x
Trace: 
  (set! x 19)

Error: unhandled condition:
Compound condition has these components: 
#<record &who>
    who : "invalid reference"
#<record &message>
    message : "No binding available for x in library (anonymous)"
#<record &syntax>
    form : x
    subform : #f

Entering debugger; type "?" for help.
debug> q

> (eval '(set! compile-file 19) env)

Syntax violation: set!
Directly or indirectly imported variable cannot be assigned
Subform: compile-file
Form: (set! compile-file 19)
Trace: 
  (set! compile-file 19)

Error: unhandled condition:
Compound condition has these components: 
#<record &who>
    who : set!
#<record &message>
    message : "Directly or indirectly imported variable cannot be assigned"
#<record &syntax>
    form : (set! compile-file 19)
    subform : compile-file

Entering debugger; type "?" for help.
debug> q

> (eval 'issue-warnings env)
#<PROCEDURE include-variable-names>

> (eval '(issue-warnings) env)
#t

> (eval '(set! issue-warnings 19) env)
(19 . issue-warnings)

> (eval 'issue-warnings env)
19
@WillClinger

This comment has been minimized.

Show comment
Hide comment
@WillClinger

WillClinger Jul 3, 2017

Member

Fixed by changeset 9616118

Member

WillClinger commented Jul 3, 2017

Fixed by changeset 9616118

@WillClinger WillClinger closed this Jul 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment