Skip to content

Commit

Permalink
fix(lexer): comment indentation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Feb 6, 2024
1 parent 30f615f commit 99cc321
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
10 changes: 0 additions & 10 deletions crates/erg_parser/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,6 @@ impl Lexer /*<'a>*/ {
),
)));
}
// ignore indents if the current line is a comment
if let Some('#') = self.peek_cur_ch() {
if let Some('[') = self.peek_next_ch() {
if let Err(e) = self.lex_multi_line_comment() {
return Some(Err(e));
}
} else if let Err(e) = self.lex_comment() {
return Some(Err(e));
}
}
let mut is_valid_dedent = false;
let calc_indent_and_validate = |sum: usize, x: &usize| {
if sum + *x == spaces_len || spaces_len == 0 {
Expand Down
17 changes: 17 additions & 0 deletions crates/erg_parser/tests/comment.er
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,20 @@ aa
]#

a = 1

func() =
if True, do:
# aaa
log "hello"
# aaa
1

C = Class()
C.
# new
new() =
C::__new__()
norm self = None

# create a new instance of C
_ = C.new()

0 comments on commit 99cc321

Please sign in to comment.