From 9b175c2a0a6af4adae8047b4e5d225bc16737c1b Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 28 May 2017 22:33:47 +0200 Subject: [PATCH 2/3] Reject more definitions outside of toplevel context Since we use global tables to store those definitions it makes sense to restrict those to the toplevel only. --- core.scm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core.scm b/core.scm index 9168c2b2..cc1dd9a5 100644 --- a/core.scm +++ b/core.scm @@ -1195,6 +1195,11 @@ (name (if (pair? (cdddr x)) (fourth x) (symbol->string var)))) + (unless tl? + (quit-compiling + "~adefinition of foreign variable `~s' in non-toplevel context" + (if ln (sprintf "(~a) - " ln) "") + var)) (set! foreign-variables (cons (list var type (if (string? name) @@ -1207,6 +1212,11 @@ (let ((name (second x)) (type (strip-syntax (third x))) (conv (cdddr x))) + (unless tl? + (quit-compiling + "~adefinition of foreign type `~s' in non-toplevel context" + (if ln (sprintf "(~a) - " ln) "") + name)) (cond [(pair? conv) (let ([arg (gensym)] [ret (gensym)] ) @@ -1229,7 +1239,7 @@ ((##core#define-external-variable) (let* ((sym (second x)) (ln (get-line x)) - (name (symbol->string sym)) + (name (symbol->string sym)) (type (third x)) (exported (fourth x)) (rname (make-random-name)) ) -- 2.13.0