Fork me on GitHub
#cursive
<
2023-10-06
>
Jim Newton16:10:56

Where can I report a bug in cursive? Or is there a known bugs list I could look at first?

Jim Newton16:10:19

is that the same place?

salam18:10:06

Aren’t the tests in the case form supposed to be constants?

salam18:10:14

I think you should be using the cond form in this case.

salam18:10:54

> Takes an expression, and a set of clauses. > Each clause can take the form of either: > test-constant result-expr

salam18:10:36

Oh, so this is trying to match on a form. I see.

Jim Newton09:10:59

no the semantics of case is that the matching forms can be a constant object to match or a list of constant objects to match. In my case I provide a singleton list of constant object(s). The code works correctly, and works as documented.

Jim Newton09:10:18

the code works as intended.

Jim Newton09:10:36

an important distinction between cond and case` is that cond evaluates the forms to obtain a boolean, while case does not evaluate the forms. so the static analizer should not consider a list in this position as a function call, but rather as list of constants.

grav20:10:52

Interesting! The https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6779 say: "The test-constants are not evaluated. They must be compile-time literals, and need not be quoted" So this works:

(let [x 'foo]
    (case x
      (foo) :yo))
But reading the "need not be quoted" part, I would have expected this to work as well:
(let [x 'foo]
    (case x
      ('foo) :yo))
but that gives me No matching clause: foo

cfleming20:10:00

@U052XLL3A That’s because reader macros are expanded, but the resulting form is then not evaluated. So you’re trying to match on ((quote foo)) there. If you pass '(quote foo) as x that will work.

💡 1
cfleming20:10:49

But yes, this bug is a result of the fact that Cursive doesn’t understand that some parts of some macros (`case`, but also binding forms in e.g. let) aren’t evaluated. I’ll try to fix that.