jscl icon indicating copy to clipboard operation
jscl copied to clipboard

Function EXPORT not working as expected while compiling.

Open VitoVan opened this issue 2 years ago • 0 comments
trafficstars

Sample code:

(defpackage :common-lisp-user)

(defpackage :c
  (:use cl)
  (:export
   :hello
   ))

(in-package :c)

(defun hello ()
  (#j:console:log "Hello"))

(defun hey ()
  (#j:console:log "Hey"))

(export 'hey)

(in-package :cl-user)

(c:hello)
(c:hey)

As we can see, this piece of code exports two functions, one is hello the other is hey.

This piece of code work as intended in the REPL:

imagen

But while I tried to compile it:

sbcl --load jscl.lisp \
     --eval '(jscl:bootstrap)' \
     --eval '(jscl:compile-application (list "~/source/test-export.lisp") "~/source/test-export.js")' \
     --eval '(quit)'

Something weird will happen:

Compiling ~/source/test-export.lisp...

debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {10010A8073}>:
  The symbol `"HEY"' is not external in the package #<PACKAGE "C">.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [CONTINUE] Ignore runtime option --eval "(jscl:compile-application (list \"~/source/test-export.lisp\") \"~/source/test-export.js\")".
  1: [ABORT   ] Skip rest of --eval and --load options.
  2:            Skip to toplevel READ/EVAL/PRINT loop.
  3: [EXIT    ] Exit SBCL (calling #'EXIT, killing the process).

(JSCL::READ-SYMBOL "c:hey")
   source: (ERROR "The symbol `~S' is not external in the package ~S." NAME
                  PACKAGE)
0]
*

I think it should be confident to treat this as a bug, so I post it here as an issue (instead of a discussion).

VitoVan avatar Apr 20 '23 07:04 VitoVan