Skip to content

change match's else to _

Sorawee Porncharoenwase requested to merge sorawee/xsmith:fix-match-else into master

Consider:

(match #f
  [(list) 1]
  [else (cond
         [#f 2]
         [else 3])])

The program outputs (void) instead of 3. The reason is that else is not a keyword in match -- match simply binds the identifier else to #f. This causes cond to not treat else as a keyword but as a variable, causing the unexpected answer.

Xsmith incorrectly uses else as a keyword in match throughout the codebase. Most of the uses are benign, since there's no cond or case in the "else" branch (though in the future there might be one, so it's worth fixing). Two uses have cond in the "else" branch, but the matching value is always truthy, so it happens to be benign as well. In any case, they should still be fixed.

Merge request reports