summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-01-27 10:06:53 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-01-27 10:06:53 +0100
commitb80f0a3c9fe6a0e6d88a95b0697cb64411152530 (patch)
tree63525975082b9216384c81029d51f97b4fcebc1c /src/comp/syntax/parse
parent7b67e2d27406d1bd2173c269b22a6166830357a0 (diff)
Use the method name 'unary-' for overloading negation
It's less likely to clash with something than 'neg'.

Issue #1520
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/parser.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 8b2d6cf36a7..a7bbddfee39 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1829,7 +1829,11 @@ fn parse_method_name(p: parser) -> ast::ident {
       token::BINOP(op) { p.bump(); token::binop_to_str(op) }
       token::NOT { p.bump(); "!" }
       token::LBRACKET { p.bump(); expect(p, token::RBRACKET); "[]" }
-      _ { parse_value_ident(p) }
+      _ {
+          let id = parse_value_ident(p);
+          if id == "unary" && eat(p, token::BINOP(token::MINUS)) { "unary-" }
+          else { id }
+      }
     }
 }