ocaml / tuareg

Emacs OCaml mode
GNU General Public License v3.0
360 stars 79 forks source link

Avoid unused return value warning in Emacs 30 #304

Closed mattiase closed 1 year ago

mattiase commented 1 year ago

This change silences an Emacs 30 warning about the value from match-beginning being unused.

(Although it's an Emacs development snapshot, the warning is correct and useful and will likely remain in the eventual release.)

monnier commented 1 year ago

This change silences an Emacs 30 warning about the value from match-beginning being unused.

Hmm... Removing a ((match-beginning N)) clause from a cond is not a no-op, so I'd argue your patch is incorrect. It turns out to do the right thing in our particular case (e.g., because the only time it triggers is for the last clause of a cond whose return value we don't use anyway, but still..., or because all the clauses's condition are mutually exclusive in our case), so maybe it's OK, but I'm not completely happy with it.

    Stefan
mattiase commented 1 year ago

I thought the macro was generating mutually exclusive clauses by construction: it builds a regexp on the form (or (group R1) ... (group Rn)) and generates cons clauses on the form ((match-beginning K) ...) for each K i 1..n (where there can be gaps in the numbering owing to internal groups in each regexp). Thus omitting cond clauses with no body should have no effect. If I'm wrong, could you show me how?

monnier commented 1 year ago

I thought the macro was generating mutually exclusive clauses by construction:

It does, and it additionally disregards the return value of the cond (both are needed for the removal to be correct, AFAICT). But if you rely on this, you need to add a clear comment to that effect.

mattiase commented 1 year ago

But if you rely on this, you need to add a clear comment to that effect.

Right, done.

mattiase commented 1 year ago

Right, done.

And rebased to master.