Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting broken for digits after the first in % args #671

Closed
daveliepmann opened this issue Nov 24, 2023 · 0 comments · Fixed by #672
Closed

Syntax highlighting broken for digits after the first in % args #671

daveliepmann opened this issue Nov 24, 2023 · 0 comments · Fixed by #672

Comments

@daveliepmann
Copy link
Contributor

While working on #670 I noticed that syntax highlighting for %<n> args does not match Clojure reader syntax or behavior.

Disclaimer: I acknowledge that %15 is unidiomatic and this is an insignificant corner case that shouldn't arise in 99.999% of Clojure programming. Nevertheless I'm reporting it because it's a clear bug.

Expected behavior

Reader-legal numbered percent-style parameters %1, %2...%n to shorthand-syntax anonymous functions #() should be syntax-highlighted.

Actual behavior

Only the first digit of %<n> anonymous functions #() parameters is syntax-highlighted. Additional digits are not. So %1, %2, ... %9 work, but %10 and further display incorrectly.

Screenshot 2023-11-24 at 08 44 14

Steps to reproduce the problem

It is legal Clojure to provide up to MAX_POSITIONAL_ARITY args, per Compiler.java. More than that throws an exception "Can't specify more than 20 params". This matches observed behavior, which clearly supports up to %20:

(apply #(max %1 %10 %20)
       (take 20 (range)))
;; => 19

(apply #(max %1 %10 %21)
       (take 21 (range)))
;; => syntax error: Can't specify more than 20 params
Screenshot 2023-11-24 at 11 59 17

(I don't think it's important or necessarily our job to distinguish between functional % args and syntax-legal ones, especially since the limit is parameterized (see below), so I say we fix %999 as well as %19.)

Environment & Version information

clojure-mode version

clojure-mode (version 5.18.0)

Emacs version

28.2

Operating system

macOS 13.5

daveliepmann added a commit to daveliepmann/clojure-mode that referenced this issue Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant