diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-06-15 17:51:57 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-06-15 19:30:10 -0700 |
| commit | 6c2f322f827ca2f2109bceab0b9630e624ac8810 (patch) | |
| tree | 148cb67a3523fbedb4851dd9c6fb330c1cc95f7f /src/comp/front/parser.rs | |
| parent | 67360ae61808453d308496f90e0b3faa3e8efee3 (diff) | |
| download | rust-6c2f322f827ca2f2109bceab0b9630e624ac8810.tar.gz rust-6c2f322f827ca2f2109bceab0b9630e624ac8810.zip | |
Improve and test failure behavior for malformed attributes
Diffstat (limited to 'src/comp/front/parser.rs')
| -rw-r--r-- | src/comp/front/parser.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 88d8516043b..1ee1e2cf0e5 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1451,7 +1451,19 @@ fn parse_source_stmt(&parser p) -> @ast::stmt { } } - alt (parse_item(p, item_attrs)) { + auto maybe_item = parse_item(p, item_attrs); + + // If we have attributes then we should have an item + if (vec::len(item_attrs) > 0u) { + alt (maybe_item) { + case (got_item(_)) { /* fallthrough */ } + case (_) { + ret p.err("expected item"); + } + } + } + + alt (maybe_item) { case (got_item(?i)) { auto hi = i.span.hi; auto decl = @spanned(lo, hi, ast::decl_item(i)); |
