Skip to content

error macroexpanding-all nested macro with a let binding referenced in a try-finally clause #1142

Closed
@ikappaki

Description

@ikappaki

Hi,

there appears to be an issue with macroexpanding-all when expanding a nested macro containing a let binding in a try-finally clause:

error occurred during inlining: unable to resolve symbol 'other/xxx' in this context

To reproduce

  1. create a macro in a separate namespace wih a xxx let binding referenced in a try-finally clause
(ns other)

(defmacro xtry
  []
  `(let [xxx 5]
     (try
       5
       (finally
         (inc xxx)))))
  1. In another namespace, create a macro that calls the above macro, and expands it using macroexpand-all
(ns issue
  (:require [basilisp.walk :refer [macroexpand-all]]
            [other :refer [xtry]]))

(defmacro abc [] `(xtry))

(macroexpand-all `(abc))
  1. Run the namesapce in the REPL an error is thrown by macroexpand-all
basilisp.user=> (load "/issue")

  exception: <class 'basilisp.lang.compiler.exception.CompilerException'> from <class 'basilisp.lang.compiler.exception.CompilerException'>
      phase: :inlining
    message: error occurred during inlining: unable to resolve symbol 'other/xxx' in this context
       form: (basilisp.core/inc other/xxx)
   location: <Macroexpand>:NO_SOURCE_LINE

Thanks

(I noticed this while working in a similar case with a nested time call,.The start let binding in the time macro triggering this issue should be an autogen symbol. I'll open an additional ticket for that)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions