We're updating the issue view to help you get more done. 

Namespace metadata lost in AOT compile

Description

AOT-compilation drops namespace metadata.

This also affects all of the namespaces packaged with Clojure, except clojure.core, for which metadata is explicitly added in core.clj.

Cause of the bug:

  • a namespace inherits the metadata of the symbol used to create that namespace the first time

  • the namespace is created in the load() method, that is invoked after the __init() method

  • the __init0() method creates all the Vars of the namespace

  • interning a Var in a namespace that doesn't exist forces that namespace to be created

This means that the namespace will have been already created (with nil metadata) by the time the load() method gets invoked and thus the call to in-ns will be a no-op and the metadata will be lost.

Approach: The attached patch fixes this issue by explicitely attaching the metadata to the namespace after its creation (via ns) using a .resetMeta call
Patch: 0001-CLJ-130-preserve-metadata-for-AOT-compiled-namespace.patch
Screened by:

Environment

None

Status

Assignee

Unassigned

Reporter

Stuart Sierra

Labels

Approval

Ok

Patch

Code

Fix versions

Priority

Major