jscl-project / jscl

A Lisp-to-JavaScript compiler bootstrapped from Common Lisp

Home Page:https://jscl-project.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Macros are treated as function while compiling

VitoVan opened this issue · comments

Sample Code:

(defpackage :common-lisp-user)

(defmacro hello (name)
  `(format t "Hello ~A~%" ,name))

(defmacro hello-jack ()
  (hello "Jack"))

(hello-jack)

This piece of code works well in the REPL:

imagen

But when I tried to compile it:

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

Something weird will happen:

Compiling ~/Source/github.com/VitoVan/calm/s/dev/wasm/test-macro.lisp...
; in:
;      PROGN (JSCL::%COMPILE-DEFMACRO 'HELLO-JACK
;                                 #'(LAMBDA (#:G19)
;                                     NIL
;                                     (BLOCK HELLO-JACK
;                                       (DESTRUCTURING-BIND
;                                           ()
;                                           #:G19
;                                         (HELLO "Jack")))))
;     (HELLO "Jack")
;
; caught STYLE-WARNING:
;   undefined function: COMMON-LISP-USER::HELLO
;
; compilation unit finished
;   Undefined function:
;     HELLO
;   caught 1 STYLE-WARNING condition

debugger invoked on a UNDEFINED-FUNCTION @52A00904 in thread
#<THREAD "main thread" RUNNING {10010A8073}>:
  The function COMMON-LISP-USER::HELLO is undefined.

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

restarts (invokable by number or by possibly-abbreviated name):
  0: [CONTINUE      ] Retry calling HELLO.
  1: [USE-VALUE     ] Call specified function.
  2: [RETURN-VALUE  ] Return specified values.
  3: [RETURN-NOTHING] Return zero values.
  4:                  Ignore runtime option --eval "(jscl:compile-application (list \"~/source/test-macro.lisp\") \"~/source/test-macro.js\")".
  5: [ABORT         ] Skip rest of --eval and --load options.
  6:                  Skip to toplevel READ/EVAL/PRINT loop.
  7: [EXIT          ] Exit SBCL (calling #'EXIT, killing the process).

("undefined function" "Jack")
0]

Is this a bug?