File tree 3 files changed +54
-1
lines changed
3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change
1
+ // } on same line
2
+ niam: () = { _ = 0'1; }
3
+
4
+ main: () = {
5
+ x := 0'1; // OK
6
+ if 1 { x = 1'2; } // same
7
+ assert(x == 12);
8
+ }
Original file line number Diff line number Diff line change
1
+
2
+
3
+ // === Cpp2 type declarations ====================================================
4
+
5
+
6
+ #include " cpp2util.h"
7
+
8
+ #line 1 "pure2-numeric-literal.cpp2"
9
+
10
+
11
+ // === Cpp2 type definitions and function declarations ===========================
12
+
13
+ #line 1 "pure2-numeric-literal.cpp2"
14
+ // } on same line
15
+ #line 2 "pure2-numeric-literal.cpp2"
16
+ auto niam () -> void;
17
+
18
+ auto main () -> int;
19
+
20
+ // === Cpp2 function definitions =================================================
21
+
22
+ #line 1 "pure2-numeric-literal.cpp2"
23
+
24
+ #line 2 "pure2-numeric-literal.cpp2"
25
+ auto niam () -> void{static_cast <void >(0'1 ); }
26
+
27
+ auto main () -> int{
28
+ auto x {0'1 }; // OK
29
+ if (1 ) {x = 1'2 ; }// same
30
+ cpp2::Default.expects (std::move (x) == 12 , " " );
31
+ }
32
+
Original file line number Diff line number Diff line change @@ -719,6 +719,7 @@ auto process_cpp2_line(
719
719
auto prev2 = ' ' ;
720
720
auto in_string_literal = false ;
721
721
auto in_char_literal = false ;
722
+ auto in_numeric_literal = false ;
722
723
723
724
for (auto i = colno_t {0 }; i < ssize (line); ++i)
724
725
{
@@ -782,10 +783,22 @@ auto process_cpp2_line(
782
783
if (prev != ' \\ ' || prev2 == ' \\ ' ) { in_string_literal = true ; }
783
784
784
785
break ;case ' \' ' :
785
- if (prev != ' \\ ' || prev2 == ' \\ ' ) { in_char_literal = true ; }
786
+ if (!in_numeric_literal && (prev != ' \\ ' || prev2 == ' \\ ' ))
787
+ {
788
+ in_char_literal = true ;
789
+ }
786
790
787
791
break ;default : ;
788
792
}
793
+ if (in_numeric_literal)
794
+ {
795
+ // Note: this allows _ but that will be caught elsewhere
796
+ if (!is_identifier_continue (line[i]) && line[i] != ' \' ' )
797
+ in_numeric_literal = false ;
798
+ }
799
+ // either decimal or other numeric literal starting with 0
800
+ else if (line[i] >= ' 0' && line[i] <= ' 9' )
801
+ in_numeric_literal = true ;
789
802
}
790
803
791
804
prev2 = prev;
You can’t perform that action at this time.
0 commit comments