Bug 21849 – UTF8: -verrors=context doesn't respect multibyte characters

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-22T11:40:51Z
Last change time
2021-04-23T02:36:48Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2021-04-22T11:40:51Z
For instance: --- void main() { string straße = 42; } --- Will report the wrong column number in the conversion error. --- utf8error.d(3,22): Error: cannot implicitly convert expression 42 of type int to string string straße = 42; ^ --- The diagnostic should instead be: --- utf8error.d(3,21): Error: cannot implicitly convert expression 42 of type int to string string straße = 42; ^ ---
Comment #1 by ibuclaw — 2021-04-22T11:51:43Z
Reason is that column tracking just uses simple pointer subtraction. https://github.com/dlang/dmd/blob/db13c6c948b4724ad8235c7063feba1241f685b4/src/dmd/lexer.d#L2291 This works when a line only consists of byte characters.
Comment #2 by ibuclaw — 2021-04-22T23:25:28Z
(In reply to Iain Buclaw from comment #1) > Reason is that column tracking just uses simple pointer subtraction. > > https://github.com/dlang/dmd/blob/db13c6c948b4724ad8235c7063feba1241f685b4/ > src/dmd/lexer.d#L2291 > Nope, I've changed my mind. This should be handled by the dmd.errors diagnostic routines. The location held by Loc is correct, as it is the raw byte column number.
Comment #3 by ibuclaw — 2021-04-22T23:37:50Z
See instead verrorPrint: https://github.com/dlang/dmd/blob/db13c6c948b4724ad8235c7063feba1241f685b4/src/dmd/errors.d#L370-L375 The line is extracted by the FileCache, what needs fixing is the foreach() loop that prints the leading spaces before the caret.
Comment #4 by dlang-bot — 2021-04-23T00:40:31Z
@ibuclaw created dlang/dmd pull request #12460 "fix Issue 21849 - UTF8: -verrors=context doesn't respect multibyte characters" fixing this issue: - fix Issue 21849 - UTF8: -verrors=context doesn't respect multibyte characters https://github.com/dlang/dmd/pull/12460
Comment #5 by dlang-bot — 2021-04-23T02:36:48Z
dlang/dmd pull request #12460 "fix Issue 21849 - UTF8: -verrors=context doesn't respect multibyte characters" was merged into master: - 973a0e1f7668a4a7bb534e2d47ef8e5327cf4c74 by Iain Buclaw: fix Issue 21849 - UTF8: -verrors=context doesn't respect multibyte characters https://github.com/dlang/dmd/pull/12460