Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#1152 closed defect (wontfix)

Reserved pattern symbols break when a binding of the same name exists

Reported by: syn Owned by: ashinn
Priority: major Milestone: someday
Component: extensions Version: 4.9.x
Keywords: matchable egg Cc:
Estimated difficulty:


When reserved pattern symbols like ? or _ are bound in the lexical environment of a match expression, they don't work anymore:

(import matchable)

(let ((? 1))
  (match '(x y)
    ((? odd?) (print ?))))

(match '(x y)
  ((_ _) (print 'ok)))

(let ((_ 1))
  (match '(x y)
    ((_ _) (print 'ok))))


$ csc matchbug.scm && ./matchbug

Error: (match) no matching pattern

	Call history:

	matchbug.scm:5: print	  
	matchbug.scm:8: print	  
	matchbug.scm:10: failure391	  
	matchbug.scm:10: error	  	<--

Change History (3)

comment:1 Changed 5 years ago by syn

Just for the record: The same happens with Chibi 0.7.

comment:2 Changed 5 years ago by ashinn

  • Resolution set to wontfix
  • Status changed from new to closed

This is basically just hygiene working as expected, and gives
that result for the same reason that

(let ((else #f))

(cond (else #t) (#t #f)))

returns #f.

Admittedly this is one of those cases where it's not useful to
match the operator position id against the current lexical scope
and one might be tempted to deliberately match unhygienically.
However, this may change in future versions. Moreover,
other macros which expand into match may depend on the
fact that inserted identifiers match hygienically.

comment:3 Changed 5 years ago by syn

Indeed, we just discussed this issue on IRC and came to the same conclusion. I guess it's just a fact of lifeWScheme we have to live with, then. Perhaps it would be worthwhile to add a caveat section about this to the manual?

Anyhow, thanks for the quick response!

Note: See TracTickets for help on using tickets.