about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/parser/src/shortcuts.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/parser/src/shortcuts.rs b/crates/parser/src/shortcuts.rs
index 680a70997d4..2beb3c3ef0d 100644
--- a/crates/parser/src/shortcuts.rs
+++ b/crates/parser/src/shortcuts.rs
@@ -190,7 +190,7 @@ impl Builder<'_, '_> {
 
     fn do_float_split(&mut self, has_pseudo_dot: bool) {
         let text = &self.lexed.range_text(self.pos..self.pos + 1);
-        self.pos += 1;
+
         match text.split_once('.') {
             Some((left, right)) => {
                 assert!(!left.is_empty());
@@ -216,8 +216,26 @@ impl Builder<'_, '_> {
                     self.state = State::PendingExit;
                 }
             }
-            None => unreachable!(),
+            None => {
+                // illegal float literal which doesn't have dot in form (like 1e0)
+                // we should emit an error node here
+                (self.sink)(StrStep::Error { msg: "illegal float literal", pos: self.pos });
+                (self.sink)(StrStep::Enter { kind: SyntaxKind::ERROR });
+                (self.sink)(StrStep::Token { kind: SyntaxKind::FLOAT_NUMBER, text: text });
+                (self.sink)(StrStep::Exit);
+
+                // move up
+                (self.sink)(StrStep::Exit);
+
+                self.state = if has_pseudo_dot {
+                    State::Normal
+                } else {
+                    State::PendingExit
+                };
+            }
         }
+
+        self.pos += 1;
     }
 }