Skip to content

[SR-13852] Diagnostics calculates column numbers incorrectly for non-ASCII source lines #56250

Open
@WowbaggersLiquidLunch

Description

@WowbaggersLiquidLunch
Previous ID SR-13852
Radar rdar://problem/71385575
Original Reporter @WowbaggersLiquidLunch
Type Bug

Attachment: Download

Environment

macOS 10.15.7 (19H15)

Apple Swift version 5.3.2 (swiftlang-1200.0.44.1 clang-1200.0.32.28)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI
Assignee None
Priority Medium

md5: a9c18eeec75c2236196435a189405308

Issue Description:

When compiling this buggy source (also attached to this issue):

let abc: String
let abĉ: String
let abê: String
let 甲乙丙: String
let abc: String
    abc = 0   // indented with a character tabulation (U+0009)
abĉ = 0           // ĉ is U+0063 followed by U+0302
abê = 0           // ê is U+00EA
甲乙丙 = 0           // 甲 is U+7532; 乙 is U+4E59; 丙 is U+4E19
abc = 0           // a is U+FF41; b is U+FF42; c is U+FF43

the compiler gives the following diagnosis:

column.swift:6:8: error: cannot assign value of type 'Int' to type 'String'
        abc = 0   // indented with a character tabulation (U+0009)
              ^
column.swift:7:9: error: cannot assign value of type 'Int' to type 'String'
abĉ = 0           // ĉ is U+0063 followed by U+0302
column.swift:8:8: error: cannot assign value of type 'Int' to type 'String'
abê = 0           // ê is U+00EA
column.swift:9:13: error: cannot assign value of type 'Int' to type 'String'
甲乙丙 = 0           // 甲 is U+7532; 乙 is U+4E59; 丙 is U+4E19
column.swift:10:13: error: cannot assign value of type 'Int' to type 'String'
abc = 0           // a is U+FF41; b is U+FF42; c is U+FF43

Only the column number for line 6 is calculated correctly.

Column number for line 7 is offset by 2.

Column number for line 8 is offset by 1.

Column numbers for line 9 and 10 are offset by 6 if each character takes 1 column, or offset by 3 if each each character takes 2 columns, or correct if each character takes 3 columns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions