Skip to content

single-clause-match-to-match-define rule buggy with shadowing #464

@jackfirth

Description

@jackfirth

As seen in racket/typed-racket#1458, the single-clause-match-to-match-define rule refactors this code:

(define (f x)
  (match x
    [(list x) x]))

Into this code:

(define (f x)
  (match-define (list x) x)
  x)

But this change is broken. In the new code, the x on the right-hand-side of the match-define expression is bound to the x in the (list x) pattern. This is because match-define has binding semantics similar to define, while match is closer to let. I'll have to add a check to that rule to ensure this case doesn't get rewritten.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions