Skip to content

Rule rewriting used on LHS SetDelayed inside a Condition #1789

Description

@rocky

Description

I am seeing rule section matching and evaluation performed on a left-hand-side pattern in a SetDelayed operation when the LHS contains a Condition.

This does not appear to be happening in WMA.

How to Reproduce and Output Given

In[1]:= dateQ[any___] := False (* fallthrough *)
In[2]:= dateQ[y_, m_, d_, Julian]/; 1 <= m <= 3 := 1 <= d <= {31, 28, 31}[[m]]]
SetDelayed::write: Tag False in False /; 1m3 is Protected.
Out[3]= $Failed
Image

Expected behavior

No error

Additional context

I note that Condition has attribute HoldRest so dateQ[y_, m_, d_, Julian] is subject to rule replacement. But is it?

Should any expression with y_, m_ (or more generally any Pattern expression) get considered as a placeholder or a variable in substitutions?

This one bug prevents us from loading Calendar.m

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions