Skip to content

Can't require a namespace in a try block and use it simulaneously #1070

Closed
@ikappaki

Description

@ikappaki

Hi,

I can't seem to be able to require a namespace as and use it simultaneously in a try form

  exception: <class 'basilisp.lang.compiler.exception.CompilerException'>
      phase: :analyzing
    message: unable to resolve symbol 'abc/read-string' in this context

To reproduce

  1. Open up the REPL and attempt to require and use basilisp.edn with an alias, an unable to resolve symbol error is thrown
basilisp.user=>   (try (require '[basilisp.edn :as abc])
                       (println :x abc/read-string)
                       (finally :done))

  exception: <class 'basilisp.lang.compiler.exception.CompilerException'>
      phase: :analyzing
    message: unable to resolve symbol 'abc/read-string' in this context
       form: abc/read-string
   location: <REPL Input>:2

The same works fine in a do block

basilisp.user=>   (do (require '[basilisp.edn :as abc])
                       (println :x abc/read-string))
:x <function read_string at 0x0000019460C6E520>
il

A workaround is to use requiring-resolve

basilisp.user=>   (try (let [rs (requiring-resolve 'basilisp.edn/read-string)]
                         (println :x @rs))
                       (finally :done))
:x <function read_string at 0x0000019460C6E520>
nil

(maybe has the same root cause as #1065?)

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