Skip to content

failure when try to define and subsequently call a macro in a try block #1086

Open
@ikappaki

Description

@ikappaki

Hi,

it doesn't seem to be possible to define and subsequently call a macro inside a try block

error occurred during macroexpansion: 'Unbound' object is not callable

To reproduce,
open the nREPL and define and call a trivial macro inside a try block, it fails with the above error

> basilisp repl
basilisp.user=> (try
                  (defmacro abc []
                    '(println 5))
                  (abc)

                  (catch Exception e
                    e))


  exception: <class 'TypeError'> from <class 'basilisp.lang.compiler.exception.CompilerException'>
      phase: :macroexpansion
    message: error occurred during macroexpansion: 'Unbound' object is not callable
       form: (abc)
   location: <REPL Input>:4

The same works fine at the top level

> basilisp repl
basilisp.user=> (defmacro abc []
                    '(println 5))
                  (abc)
5
nil

Is there a technical constraint perhaps that prevents macros from being defined anywhere else other than the top level?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions