Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove oct/bin floating point literals #12687

Merged
merged 5 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions spec/compiler/lexer/lexer_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ describe "Lexer" do
assert_syntax_error "0o200_i8", "0o200 doesn't fit in an Int8"
assert_syntax_error "0b10000000_i8", "0b10000000 doesn't fit in an Int8"

assert_syntax_error "0b11_f32", "unexpected token: \"f32\""
assert_syntax_error "0o73_f64", "unexpected token: \"f64\""

# 2**31 - 1
it_lexes_i32 [["0x7fffffff", "2147483647"], ["0o17777777777", "2147483647"], ["0b1111111111111111111111111111111", "2147483647"]]
it_lexes_i32 [["0x7fffffff_i32", "2147483647"], ["0o17777777777_i32", "2147483647"], ["0b1111111111111111111111111111111_i32", "2147483647"]]
Expand Down
1 change: 1 addition & 0 deletions src/compiler/crystal/syntax/lexer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@ module Crystal
raise("unexpected '_' in number", @token, (current_pos - start)) if peek_next_char == '_'
break unless peek_next_char.in?('0'..'9')
when 'i', 'u', 'f'
break if current_char == 'f' && base != 10
before_suffix_pos = current_pos
@token.number_kind = consume_number_suffix
next_char
Expand Down