Skip to content

Commit

Permalink
scanner: allow exponent in string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Oct 8, 2024
1 parent 4167e4f commit feccdf3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/scanner/scanner.v
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ fn (mut s Scanner) ident_dec_number() string {
if !s.pref.translated {
s.error('this number has unsuitable digit `${first_wrong_digit.str()}`')
}
} else if s.text[s.pos - 1] in [`e`, `E`] {
} else if s.text[s.pos - 1] in [`e`, `E`] && !s.is_inside_string {
// error check: 5e
s.pos-- // adjust error position
s.error('exponent has no digits')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,9 @@ fn test_interpo_non_ascii_characters() {
hello := '你好'
assert '${hello},世界!' == '你好,世界!'
}

fn test_float_exponent_sign() {
a := 1.234
assert '${a:4.1e}' == ' 1.2'
assert '${a:4.1E}' == ' 1.2'
}

0 comments on commit feccdf3

Please sign in to comment.