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

scanner: remove redundancy from the message suggesting to use quotes instead of backticks for characters #22390

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 3 additions & 6 deletions vlib/v/scanner/scanner.v
Original file line number Diff line number Diff line change
Expand Up @@ -1640,19 +1640,16 @@ pub fn (mut s Scanner) ident_char() string {
s.error_with_pos('invalid character literal `${orig}` => `${c}` ([${err_info.join(', ')}]) (escape sequence did not refer to a singular rune)',
lspos)
} else if u.len == 0 {
s.add_error_detail_with_pos('use quotes for strings, backticks for characters',
lspos)
s.add_error_detail('use quotes for strings, backticks for characters')
s.error_with_pos('invalid empty character literal `${orig}`', lspos)
} else {
s.add_error_detail_with_pos('use quotes for strings, backticks for characters',
lspos)
s.add_error_detail('use quotes for strings, backticks for characters')
s.error_with_pos('invalid character literal `${orig}` => `${c}` ([${err_info.join(', ')}]) (more than one character)',
lspos)
}
}
} else if c.ends_with('\n') {
s.add_error_detail_with_pos('use quotes for strings, backticks for characters',
lspos)
s.add_error_detail('use quotes for strings, backticks for characters')
s.error_with_pos('invalid character literal, use \`\\n\` instead', lspos)
} else if c.len > len {
ch := c[c.len - 1]
Expand Down
8 changes: 1 addition & 7 deletions vlib/v/scanner/tests/empty_character_literal_err.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,4 @@ vlib/v/scanner/tests/empty_character_literal_err.vv:2:7: error: invalid empty ch
| ^
3 | println(a)
4 | }
Details:
vlib/v/scanner/tests/empty_character_literal_err.vv:2:7: details: use quotes for strings, backticks for characters
1 | fn main() {
2 | a := ``
| ^
3 | println(a)
4 | }
Details: use quotes for strings, backticks for characters
5 changes: 1 addition & 4 deletions vlib/v/scanner/tests/invalid_character_literal_err_1.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
vlib/v/scanner/tests/invalid_character_literal_err_1.vv:1:6: error: invalid character literal `\n\t` => `\n\t` ([`\n`, `\t`]) (more than one character)
1 | a := `\n\t`
| ^
Details:
vlib/v/scanner/tests/invalid_character_literal_err_1.vv:1:6: details: use quotes for strings, backticks for characters
1 | a := `\n\t`
| ^
Details: use quotes for strings, backticks for characters
5 changes: 1 addition & 4 deletions vlib/v/scanner/tests/invalid_character_literal_err_2.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
vlib/v/scanner/tests/invalid_character_literal_err_2.vv:1:6: error: invalid character literal `\nb` => `\nb` ([`\n`, `b`]) (more than one character)
1 | a := `\nb`
| ^
Details:
vlib/v/scanner/tests/invalid_character_literal_err_2.vv:1:6: details: use quotes for strings, backticks for characters
1 | a := `\nb`
| ^
Details: use quotes for strings, backticks for characters
8 changes: 1 addition & 7 deletions vlib/v/scanner/tests/newline_character_literal_err.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,4 @@ vlib/v/scanner/tests/newline_character_literal_err.vv:2:7: error: invalid charac
| ^
3 | `
4 | println(a)
Details:
vlib/v/scanner/tests/newline_character_literal_err.vv:2:7: details: use quotes for strings, backticks for characters
1 | fn main() {
2 | a := `
| ^
3 | `
4 | println(a)
Details: use quotes for strings, backticks for characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,4 @@ vlib/v/scanner/tests/unknown_escape_sequence_in_ident_char_1_err.vv:2:6: error:
| ^
3 | `
4 | }
Details:
vlib/v/scanner/tests/unknown_escape_sequence_in_ident_char_1_err.vv:2:6: details: use quotes for strings, backticks for characters
1 | fn main() {
2 | _ = `\
| ^
3 | `
4 | }
Details: use quotes for strings, backticks for characters
Loading