mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
lexer: fix nullsafe arrow token skipping too many characters
This commit is contained in:
parent
948c2cf561
commit
1e94b05ba6
@ -237,7 +237,7 @@ impl Lexer {
|
||||
TokenKind::QuestionColon
|
||||
} else if self.try_read("->") {
|
||||
self.col += 1;
|
||||
self.skip(3);
|
||||
self.skip(2);
|
||||
TokenKind::NullsafeArrow
|
||||
} else {
|
||||
TokenKind::Question
|
||||
|
@ -3177,6 +3177,13 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nullsafe_operator() {
|
||||
assert_ast("<?php $a?->b;", &[
|
||||
expr!(Expression::NullsafePropertyFetch { target: Box::new(Expression::Variable { name: "a".into() }), property: Box::new(Expression::Identifier { name: "b".into() }) })
|
||||
]);
|
||||
}
|
||||
|
||||
fn assert_ast(source: &str, expected: &[Statement]) {
|
||||
let mut lexer = Lexer::new(None);
|
||||
let tokens = lexer.tokenize(source).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user