Skip to content

Catch errors from invalid macro while expanding#21

Open
JesperAxelsson wants to merge 1 commit into
lem-project:mainfrom
JesperAxelsson:fix-macro-expand-throwing-on-invalid-macro
Open

Catch errors from invalid macro while expanding#21
JesperAxelsson wants to merge 1 commit into
lem-project:mainfrom
JesperAxelsson:fix-macro-expand-throwing-on-invalid-macro

Conversation

@JesperAxelsson
Copy link
Copy Markdown

Fix Lem UI deadlock by catching compiler errors in macrostep-expand-1

When expanding a syntactically malformed macro, macrostep-expand-1 fails
to catch low-level compiler errors. These uncaught errors bypass the local
error-message check and trigger the interactive Swank/Micros debugger.

Because the Lem UI thread is blocked synchronously waiting for an
(:ok ...) or (:error ...) response list, the editor deadlocks.

This wraps the expansion step in macrostep-expand-1 with a handler-case
ensuring fatal compiler crashes are safely caught
and returned as standard (:error ...) lists.

How to recreate in lem

If you have a broken macro like this:

(defmacro borked-macro (a b)
  (`(+ ,a ,b)))

And try to expand it in a buffer with lisp-macrostep-expand or C-c enter.

(borked-macro 1 2)

Let me know if there anything you want to change/add.

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

Successfully merging this pull request may close these issues.

1 participant