diff --git a/core/parse.go b/core/parse.go index 47c65decf..5d3b81d65 100644 --- a/core/parse.go +++ b/core/parse.go @@ -1514,6 +1514,7 @@ func parseSymbol(obj Object, ctx *ParseContext) Expr { panic(&ParseError{obj: obj, msg: "Unable to resolve symbol: " + sym.ToString(false)}) } if DIALECT == CLJS && sym.ns == nil { + // Check if this is a "callable namespace" ns := ctx.GlobalEnv.FindNamespace(sym) if ns == nil { ns = ctx.GlobalEnv.CurrentNamespace().aliases[sym.name] @@ -1522,6 +1523,11 @@ func parseSymbol(obj Object, ctx *ParseContext) Expr { ns.isUsed = true return NewSurrogateExpr(obj) } + // See if this is a JS interop (i.e. Math.PI) + parts := strings.Split(sym.Name(), ".") + if len(parts) > 1 { + return parseSymbol(DeriveReadObject(obj, MakeSymbol(parts[0])), ctx) + } } symNs := ctx.GlobalEnv.NamespaceFor(ctx.GlobalEnv.CurrentNamespace(), sym) if symNs == nil || symNs == ctx.GlobalEnv.CurrentNamespace() { diff --git a/tests/linter/cljs-interop/input.cljs b/tests/linter/cljs-interop/input.cljs new file mode 100644 index 000000000..dfa3624dd --- /dev/null +++ b/tests/linter/cljs-interop/input.cljs @@ -0,0 +1,4 @@ +js/Math.PI +(def m js/Math) +m.PI +g.PI diff --git a/tests/linter/cljs-interop/output.txt b/tests/linter/cljs-interop/output.txt new file mode 100644 index 000000000..7463af43c --- /dev/null +++ b/tests/linter/cljs-interop/output.txt @@ -0,0 +1 @@ +tests/linter/cljs-interop/input.cljs:4:1: Parse error: Unable to resolve symbol: g