Ticket #1437: toplevel-evals.diff

File toplevel-evals.diff, 2.9 KB (added by sjamaan, 5 years ago)

Attempt that fails

  • batch-driver.scm

    diff --git a/batch-driver.scm b/batch-driver.scm
    index ebd62ea6..883dd6cf 100644
    a b  
    187187                             `((uses ,@default-units)))))
    188188                     ,@(if explicit-use-flag
    189189                           '()
    190                            `((import ,@default-imports)))
    191                      ;; Ensure the same default environment is
    192                      ;; available from eval, as well.  See notes at
    193                      ;; the end of internal.scm and modules.scm.
    194                      ,@(if explicit-use-flag
    195                            '()
    196                            `((scheme#eval '(import-for-syntax ,@default-syntax-imports))
    197                              (scheme#eval '(import ,@default-imports))))))
     190                           `((import ,@default-imports)))))
    198191        (verbose (memq 'verbose options))
    199192        (outfile (cond ((memq 'output-file options)
    200193                        => (lambda (node)
  • eval.scm

    diff --git a/eval.scm b/eval.scm
    index 0d577c0d..2f5b2caa 100644
    a b  
    739739  (make-parameter
    740740   (lambda (x #!optional env)
    741741     (let ((se (##sys#current-environment)))
     742       ;; When se is empty, it's the first time eval was called:
     743       ;; ensure an active default environment.  We do it here because
     744       ;; eval does not work yet at the end of modules.scm, and we
     745       ;; don't want to inject calls into every toplevel (see #1437)
     746       (when (null? se)
     747         ((compile-to-closure
     748           `(##core#begin (import-for-syntax ,@default-syntax-imports)
     749                          (import ,@default-imports))
     750           '() se #f #f #f #t) '()))
    742751       (cond (env
    743752              (##sys#check-structure env 'environment 'eval)
    744753              (let ((se2 (##sys#slot env 2)))
  • modules.scm

    diff --git a/modules.scm b/modules.scm
    index 8e5179c6..2847a1fa 100644
    a b  
    11331133
    11341134;; Ensure default modules are available in "eval", too
    11351135;; TODO: Figure out a better way to make this work for static programs.
    1136 ;; The actual imports are handled by the prelude inserted by
    1137 ;; batch-driver.scm
     1136;; The actual imports are handled lazily by eval when first called.
    11381137(include "chicken.base.import.scm")
    11391138(include "chicken.syntax.import.scm")
  • tests/scrutiny.expected

    diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected
    index 75910d11..f4ec7931 100644
    a b Warning: at toplevel: 
    4343  assignment of value of type `fixnum' to toplevel variable `scheme#car' does not match declared type `(forall (a) (procedure scheme#car ((pair a *)) a))'
    4444
    4545Warning: at toplevel:
    46   expected a single result in `let' binding of `g118', but received 2 results
     46  expected a single result in `let' binding of `g127', but received 2 results
    4747
    4848Warning: at toplevel:
    49   in procedure call to `g118', expected a value of type `(procedure () *)' but was given a value of type `fixnum'
     49  in procedure call to `g127', expected a value of type `(procedure () *)' but was given a value of type `fixnum'
    5050
    5151Note: in toplevel procedure `foo':
    5252  expected a value of type boolean in conditional, but was given a value of type `(procedure bar () *)' which is always true: