Serious bug in MatchQ causes crashes and incorrect results
- To: mathgroup at smc.vnet.net
- Subject: [mg28206] Serious bug in MatchQ causes crashes and incorrect results
- From: Jeff DuMonthier <jeff at lheapop.gsfc.nasa.gov>
- Date: Wed, 4 Apr 2001 04:13:28 -0400 (EDT)
- Organization: NASA GSFC
- Sender: owner-wri-mathgroup at wolfram.com
I recently posted a question in this group asking how I could do complex pattern matching and default arguments in function (delayed set) definitions. The best way seemed to be to use the argument list definition for the defaults and MatchQ in the body to check arguments. This is an example of what I was doing: getFile[dirs_:{},file_]:=Module[{ vars... }, If[! MatchQ[dirs,{_String...}], Message[getFile::err1];Abort[] ]; ... ]; Although my test cases worked, when I tried to actually use the code I encountered serious problems. Running version 4.0.1 for Macintosh (OS 9.1) I started experiencing frequent system crashes (freezing). Usually this would occur while one of these functions was being executed. Once it froze when closing the help browser. I edited just the MatchQ expressions out of the code and it ran with no problems. Running version 3.0 under Solaris the MatchQ conditions did not always return the correct results. For example, the code fragment above would usually but not always abort on the check shown, even when the first argument was a list containing one or more strings, i.e. {"aaa"}. This is the first case I have found (without using Mathlink) where Mathematica crashes or returns erroneous and inconsistent results rather than cryptic error messages. -Jeff DuMonthier