Skip to content

cider-ns-form-p produces false positive when the form contains namespace-like string. #3754

Closed
@a13

Description

@a13

Hi, while working on https://github.com/scicloj/clay (we have Clojure file parser tests there) I hit a problem, so

I have code like this in a file

(ns wtf)

(def foo
  "
(ns bar)
"
  )

Expected behavior

foo evals to #'wtf/foo

Actual behavior

#'user/foo

Steps to reproduce the problem

put the code above into a file, start repl, eval it in cider

Environment & Version information

CIDER version information

;; CIDER 1.16.0 (Kherson), babashka.nrepl 0.0.6-SNAPSHOT
;; Babashka 1.3.191

Lein / Clojure CLI version

Babashka 1.3.191

Emacs version

29.4

Operating system

Ubuntu 22.04

JDK distribution

Babashka 1.3.191

The problems is the regex used in cider-ns-form-p - "^[[:space:]]*\(ns\\([[:space:]]*$\\|[[:space:]]+\\)" treats namespace in a string as a real namespace, so cider-interactive-eval evals it in user namespace instead of the current one.

I tried to fix it by myself but unfortunately, Emacs regexes don't support look ahead, so probably we should discuss the way it should be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueA simple tasks suitable for first-time contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions