14
$\begingroup$

Bug introduced in 8.0.4 or earlier and persists through 11.1.1

Thank you for bringing this to our attention. I have filed a report with our developers.


Why does this

{42.`}~MatchQ~(x0 : _List) {42.`}~MatchQ~(x0 : {___}) {42.`}~MatchQ~(x0 : _List : {1.}) {42.`}~MatchQ~(x0 : {___} : {1.}) 

give

True

True

True

False

Instead of all true?

$\endgroup$
6
  • 2
    $\begingroup$ In addition {42.}~MatchQ~(x0 : {__} : {1.}) yields False but {42.}~MatchQ~(x0 : {_} : {1.}) yields True. And Traceing doesn't illuminate anything: Trace[{42.}~MatchQ~(x0 : {___} : {1.})] yields {MatchQ[{42.}, x0 : {___} : {1.}], False}. $\endgroup$ Commented Aug 25, 2016 at 16:10
  • $\begingroup$ So I guess this is a bug? $\endgroup$ Commented Aug 25, 2016 at 20:06
  • $\begingroup$ I filed a report. $\endgroup$ Commented Aug 25, 2016 at 20:25
  • 2
    $\begingroup$ similar: (72290). $\endgroup$ Commented Aug 25, 2016 at 21:06
  • $\begingroup$ @WReach We have to get Daniel here ;) $\endgroup$ Commented Aug 26, 2016 at 1:52

1 Answer 1

4
$\begingroup$

This bug is fixed in our next release. Note, however, that, that the use of Optional generates a warning now, as the optional value could never possible be used in such pattern:

In[14]:= {42.`}~MatchQ~(x0 : {___} : {1.}) During evaluation of In[14]:= Optional::optloose: Optional pattern x0:{___}:{1.} has no enclosing pattern so no optional value can be matched. Out[14]= True 
$\endgroup$
2
  • $\begingroup$ Thanks. I was also notified that this is fixed in 11.2. $\endgroup$ Commented Nov 10, 2017 at 15:44
  • $\begingroup$ Now x /. b_: 0 + x :> -b fails in 11.2 but works in 11.0.1. To get it to work in 11.2 had to add parentheses: x /. (b_: 0) + x :> -b $\endgroup$ Commented Jan 29, 2018 at 16:39

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.