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

This commit is contained in:
Jose Mendoza 2024-10-02 14:49:52 -04:00 committed by GitHub
parent c01186c729
commit 2b546c4fa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 35 deletions

View File

@ -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)', s.error_with_pos('invalid character literal `${orig}` => `${c}` ([${err_info.join(', ')}]) (escape sequence did not refer to a singular rune)',
lspos) lspos)
} else if u.len == 0 { } else if u.len == 0 {
s.add_error_detail_with_pos('use quotes for strings, backticks for characters', s.add_error_detail('use quotes for strings, backticks for characters')
lspos)
s.error_with_pos('invalid empty character literal `${orig}`', lspos) s.error_with_pos('invalid empty character literal `${orig}`', lspos)
} else { } else {
s.add_error_detail_with_pos('use quotes for strings, backticks for characters', s.add_error_detail('use quotes for strings, backticks for characters')
lspos)
s.error_with_pos('invalid character literal `${orig}` => `${c}` ([${err_info.join(', ')}]) (more than one character)', s.error_with_pos('invalid character literal `${orig}` => `${c}` ([${err_info.join(', ')}]) (more than one character)',
lspos) lspos)
} }
} }
} else if c.ends_with('\n') { } else if c.ends_with('\n') {
s.add_error_detail_with_pos('use quotes for strings, backticks for characters', s.add_error_detail('use quotes for strings, backticks for characters')
lspos)
s.error_with_pos('invalid character literal, use \`\\n\` instead', lspos) s.error_with_pos('invalid character literal, use \`\\n\` instead', lspos)
} else if c.len > len { } else if c.len > len {
ch := c[c.len - 1] ch := c[c.len - 1]

View File

@ -4,10 +4,4 @@ vlib/v/scanner/tests/empty_character_literal_err.vv:2:7: error: invalid empty ch
| ^ | ^
3 | println(a) 3 | println(a)
4 | } 4 | }
Details: Details: use quotes for strings, backticks for characters
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 | }

View File

@ -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) 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` 1 | a := `\n\t`
| ^ | ^
Details: Details: use quotes for strings, backticks for characters
vlib/v/scanner/tests/invalid_character_literal_err_1.vv:1:6: details: use quotes for strings, backticks for characters
1 | a := `\n\t`
| ^

View File

@ -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) 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` 1 | a := `\nb`
| ^ | ^
Details: Details: use quotes for strings, backticks for characters
vlib/v/scanner/tests/invalid_character_literal_err_2.vv:1:6: details: use quotes for strings, backticks for characters
1 | a := `\nb`
| ^

View File

@ -4,10 +4,4 @@ vlib/v/scanner/tests/newline_character_literal_err.vv:2:7: error: invalid charac
| ^ | ^
3 | ` 3 | `
4 | println(a) 4 | println(a)
Details: Details: use quotes for strings, backticks for characters
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)

View File

@ -4,10 +4,4 @@ vlib/v/scanner/tests/unknown_escape_sequence_in_ident_char_1_err.vv:2:6: error:
| ^ | ^
3 | ` 3 | `
4 | } 4 | }
Details: Details: use quotes for strings, backticks for characters
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 | }