Question: why this patmatch fails inside proc but works outside?

I can't figure this out. Same exact patmatch works in global worksheet. But fails inside a proc.

I am using same exact code. In proc, I am doing    a::anything where `a` is now local symbol ofcourse. In worksheet, it is global ofcourse. I make sure I clear `a` in worksheet each time also.

So why it pathmatch fail in the proc? I must be doing something wrong but do not see it.,
 

26148

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

restart;

26148

a:='a':
stat:=0^n:

if patmatch(stat,0^a::anything) then
     0;
  else
     stat;
  fi;

0

foo:=proc(stat)
  local a;
  if patmatch(stat,0^a::anything) then
     0;
  else
     stat;
  fi;
end proc:

#why this does not return zero as expected?
foo(stat)

0^n

 


Here is screen shot in debugger showing patmatch failed inside the proc

 

Very strange. What do I need to change in the proc to make it work as in worksheet? 

Download patmatch_in_proc.mw

Please Wait...