[CLJS-476] Reading a value from a module does not work if the module is def'ed Created: 22/Feb/13 Updated: 19/Nov/13 Resolved: 19/Nov/13
|Labels:||Compiler, bug, scope|
Referring to a value in a module can have a scoping issue when using the "static accessor" operator of module/VALUE_NAME. The static accessor works if the module is loaded into a local value but not if def'ed. This example uses the mmap module for Node.js, and successfully reads the PROT_READ value:
This correctly prints "value: 1"
However, if the value for m is def'ed instead, then the compiler assumes that the reference to m is local to the function and therefore not defined:
In this case, the value of m.PROT_READ should have been stat.core.m.PROT_READ.
On the other hand, using . syntax fixes the scoping issue:
|Comment by David Nolen [ 19/Nov/13 9:26 PM ]|
the slash syntax is reserved for real CLJS namespaces for everything else the dot syntax must be used.