Skip to content

Commit ce6e0f5

Browse files
committed
linter: eval create-ns to avoid false positives
1 parent d0f9de5 commit ce6e0f5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

core/parse.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ var (
233233
KNOWN_MACROS *Var
234234
REQUIRE_VAR *Var
235235
ALIAS_VAR *Var
236+
CREATE_NS_VAR *Var
236237
WARNINGS = Warnings{}
237238
KEYWORDS = Keywords{
238239
tag: MakeKeyword("tag"),
@@ -1230,6 +1231,13 @@ func getAliasVar(ctx *ParseContext) *Var {
12301231
return ALIAS_VAR
12311232
}
12321233

1234+
func getCreateNsVar(ctx *ParseContext) *Var {
1235+
if CREATE_NS_VAR == nil {
1236+
CREATE_NS_VAR = ctx.GlobalEnv.CoreNamespace.Resolve("create-ns")
1237+
}
1238+
return CREATE_NS_VAR
1239+
}
1240+
12331241
func checkCall(expr Expr, isMacro bool, call *CallExpr, pos Position) {
12341242
switch expr := expr.(type) {
12351243
case *FnExpr:
@@ -1379,7 +1387,11 @@ func parseList(obj Object, ctx *ParseContext) Expr {
13791387
if !reportWrongArity(f.fnExpr, c.vr.isMacro, res, pos) {
13801388
require := getRequireVar(ctx)
13811389
alias := getAliasVar(ctx)
1382-
if (c.vr.Value.Equals(require.Value) || c.vr.Value.Equals(alias.Value)) && areAllLiteralExprs(res.args) {
1390+
createNs := getCreateNsVar(ctx)
1391+
if (c.vr.Value.Equals(require.Value) ||
1392+
c.vr.Value.Equals(alias.Value) ||
1393+
c.vr.Value.Equals(createNs.Value)) &&
1394+
areAllLiteralExprs(res.args) {
13831395
Eval(res, nil)
13841396
}
13851397
}

tests/linter/ns-7/input.clj

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
(create-ns 'test.test)
12
(alias 'os 'joker.os)
3+
(alias 't 'test.test)
24

35
(os/sh "ls")
6+
(test.test/foo)
7+
(t/bar)

0 commit comments

Comments
 (0)