File tree 2 files changed +27
-0
lines changed 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,12 @@ where
357
357
if self . chr0 == Some ( '.' ) || self . at_exponent ( ) {
358
358
// Take '.':
359
359
if self . chr0 == Some ( '.' ) {
360
+ if self . chr1 == Some ( '_' ) {
361
+ return Err ( LexicalError {
362
+ error : LexicalErrorType :: OtherError ( "Invalid Syntax" . to_string ( ) ) ,
363
+ location : self . get_pos ( ) ,
364
+ } ) ;
365
+ }
360
366
value_text. push ( self . next_char ( ) . unwrap ( ) ) ;
361
367
value_text. push_str ( & self . radix_run ( 10 ) ) ;
362
368
}
@@ -416,6 +422,7 @@ where
416
422
/// like this: '1_2_3_4' == '1234'
417
423
fn radix_run ( & mut self , radix : u32 ) -> String {
418
424
let mut value_text = String :: new ( ) ;
425
+
419
426
loop {
420
427
if let Some ( c) = self . take_number ( radix) {
421
428
value_text. push ( c) ;
Original file line number Diff line number Diff line change 206
206
# Test special case for lexer, float starts with a dot:
207
207
a = .5
208
208
assert a == 0.5
209
+ assert 3.14 == float ('3.14' )
210
+ src = """
211
+ a = 3._14
212
+ """
213
+
214
+ with assert_raises (SyntaxError ):
215
+ exec (src )
216
+ src = """
217
+ a = 3.__14
218
+ """
219
+
220
+ with assert_raises (SyntaxError ):
221
+ exec (src )
222
+
223
+ src = """
224
+ a = 3.1__4
225
+ """
226
+
227
+ with assert_raises (SyntaxError ):
228
+ exec (src )
209
229
210
230
assert float .fromhex ('0x0.0p+0' ) == 0.0
211
231
assert float .fromhex ('-0x0.0p+0' ) == - 0.0
You can’t perform that action at this time.
0 commit comments