resyntax icon indicating copy to clipboard operation
resyntax copied to clipboard

Unnecessary root-level `and` patterns

Open jackfirth opened this issue 1 year ago • 0 comments

Encountered here:

#lang resyntax/test

test: "root-level and pattern can be removed when matching on a variable"
--------------------
#lang racket
(define (f xs)
  (match xs
    [(and foo (list x y ...))
     (cons x (reverse foo))]))
--------------------
--------------------
#lang racket
(define (f xs)
  (match xs
    [(list x y ...)
     (cons x (reverse xs))]))
--------------------

This applies whenever match is used on a variable and has an and pattern with an identifier as the outermost pattern in any branch.

jackfirth avatar Nov 08 '24 19:11 jackfirth