Pattern matching does not work for negative literals

Bug #912145 reported by Matt Giuca
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mars
Fix Committed
High
Matt Giuca

Bug Description

Case statements do not match negative literals. I believe this is a regression since we removed the - sign from the integer literal syntax and made it part of the expression syntax. An example:

var x :: Int
switch x:
    case 4:
        pass
    case -4:
        pass
    case _:
        pass

Need to make the minus sign an explicit part of the pattern syntax.

Tags: parser

Related branches

Revision history for this message
Matt Giuca (mgiuca) wrote :

I don't understand why the assignment statement equivalent (-4 = x) succeeds. (At least: fails correctly.)

Revision history for this message
Matt Giuca (mgiuca) wrote :

Note: The assignment statement succeeds because of a special case in parsem.unary_expr, which converts a negated integer literal to a negative integer.

Revision history for this message
Matt Giuca (mgiuca) wrote :

Fixed in trunk r1308.

Changed in mars:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.