diff --git a/crates/erg_parser/parse.rs b/crates/erg_parser/parse.rs index 44648f12..75d21c77 100644 --- a/crates/erg_parser/parse.rs +++ b/crates/erg_parser/parse.rs @@ -2168,10 +2168,11 @@ impl Parser { obj = obj.attr_expr(ident); } NatLit => { - let index = Literal::from(self.lpop()); + let index = Literal::from(token); obj = obj.tuple_attr_expr(index); } Newline => { + self.restore(token); self.restore(vis); break; } @@ -3017,7 +3018,6 @@ impl Parser { debug_exit_info!(self); return Err(()); }; - self.skip(); if let Some(args) = self .opt_reduce_args(false) .transpose() diff --git a/crates/erg_parser/tests/parse_test.rs b/crates/erg_parser/tests/parse_test.rs index 2e0f6e3b..669a10d3 100644 --- a/crates/erg_parser/tests/parse_test.rs +++ b/crates/erg_parser/tests/parse_test.rs @@ -69,7 +69,7 @@ fn exec_invalid_chunk_prs_err() -> Result<(), ()> { #[test] fn expect_failure_collections_err() -> Result<(), ()> { - expect_failure("tests/invalid_collections.er", 33) + expect_failure("tests/invalid_collections.er", 30) } #[test]