Files
swift-mirror/test/Syntax/Parser/diags.swift
Suyash Srijan 7ee6319cdc [Parse] [Sema] Update confusables diagnostic to mention the character names as well (#33105)
* [Parser] Update 'Confusables.def' file to include confusable and base character names

* [Parser] Add a new utility method to return the names of the confusable and base characters for a given confusable codepoint

* [Parser] Update diagnostic for confusable character during lexing to mention confusable and base character names

* [Sema] If there is just a single confusable character, emit a tailored diagnostic that also mentions the character names

* [Diagnostics] Add new diagnostic messages to the localization file

* [Test] Update confusables test

* [Utils] Update unicode confusables txt file and update script to regenerate confusables def file

* [Parse] Regenerate 'Confusables.def' using updated script

* [Utils] Adjust generate_confusables script based on review feedback

Fix a mistake with name mapping. Updated header comment. Fix a couple of linting issues.

* [Parse] Regenerate 'Confusables.def' file once again after script changes

* [Parse] Add the newline after end of 'getConfusableAndBaseCodepointNames' method

* [Test] Update diagnostic message in 'Syntax/Parser/diags.swift'
2020-07-27 23:15:31 +01:00

34 lines
1.6 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// REQUIRES: syntax_parser_lib
// RUN: %swift-syntax-parser-test %s -dump-diags 2>&1 | %FileCheck %s
// CHECK: [[@LINE+2]]:11 Error: consecutive statements on a line must be separated by ';'
// CHECK-NEXT: ([[@LINE+1]]:11,[[@LINE+1]]:11) Fixit: ";"
let number Int
// CHECK-NEXT: [[@LINE-1]]:11 Error: operator with postfix spacing cannot start a subexpression
// CHECK-NEXT: [[@LINE+2]]:3 Error: invalid character in source file
// CHECK-NEXT: ([[@LINE+1]]:3,[[@LINE+1]]:6) Fixit: " "
5 5
// CHECK-NEXT: [[@LINE-1]]:3 Note: unicode character '' (Figure Dash) looks similar to '-' (Hyphen Minus); did you mean to use '-' (Hyphen Minus)?
// CHECK-NEXT: ([[@LINE-2]]:3,[[@LINE-2]]:6) Fixit: "-"
// CHECK-NEXT: [[@LINE-3]]:2 Error: consecutive statements on a line must be separated by ';'
// CHECK-NEXT: ([[@LINE-4]]:2,[[@LINE-4]]:2) Fixit: ";"
// CHECK-NEXT: [[@LINE+2]]:10 Error: expected ',' separator
// CHECK-NEXT: ([[@LINE+1]]:9,[[@LINE+1]]:9) Fixit: ","
if (true false) {}
if (5 5) == 0 {}
// CHECK-NEXT: [[@LINE-1]]:7 Error: invalid character in source file
// CHECK-NEXT: ([[@LINE-2]]:7,[[@LINE-2]]:10) Fixit: " "
// CHECK-NEXT: [[@LINE-3]]:7 Note: unicode character '' (Figure Dash) looks similar to '-' (Hyphen Minus); did you mean to use '-' (Hyphen Minus)?
// CHECK-NEXT: ([[@LINE-4]]:7,[[@LINE-4]]:10) Fixit: "-"
// CHECK-NEXT: [[@LINE-5]]:11 Error: expected ',' separator
// CHECK-NEXT: ([[@LINE-6]]:6,[[@LINE-6]]:6) Fixit: ","
let dateFormatter: DateFormatter = {
let dateFormatter = DateFormatter()
return dateFormatter
}()
// CHECK-NEXT: 7 error(s) 0 warnings(s) 2 note(s)