Skip to content
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

Macros are treated as function while compiling #472

Open
VitoVan opened this issue Apr 20, 2023 · 0 comments
Open

Macros are treated as function while compiling #472

VitoVan opened this issue Apr 20, 2023 · 0 comments

Comments

@VitoVan
Copy link
Contributor

VitoVan commented Apr 20, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant