

Fix handling of carriage return. by chriseth · Pull Request #11071 · ethereum/so...
source link: https://github.com/ethereum/solidity/pull/11071
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

This does prevent the crash but I'm not sure it actually fixes the underlying issue.
I think that the problem might actually be in source->lineAtPosition()
. It seems that it strips a single \r
character from the line which is the reason why start
ends up being past the end of the line. For example if the line is \r\r\r\r
, it returns \r\r\r
. This is inconsistent with source->translatePositionToLineColumn()
, which just ignores \r
characters completely.
Also, even after the fix the locations shown in error messages seem off. For example for \rabc
you get this:
Warning: Yul is still experimental. Please use the output with care.
Error: Expected keyword "object".
--> /tmp/cr.yul:1:2:
|
abc
| ^^^
Yes, that is indeed the underlying issue, but I still think that this is the best fix. The problem with \rabc
is a different one.
Yeah, I think the problem is here:
It looks like it's meant to handle the \r
left over after stripping \n
on Windows. But for this to work correctly translatePositionToLineColumn()
should also treat that \r
in the same special way - as a part of the line ending - and it does not.
translatePositionToLineColumn()
could be causing similar problems in other places that we just haven't detected yet.
I think translatePositionToLineColumn
is perfectly implemented according to the specification. It is lineAtPosition
that is questionable.
We could change lineAtPosition
to remove all trailing whitespace....
Just curious, which specification do you mean? Do we have newline handling documented somewhere?
We could change
lineAtPosition
to remove all trailing whitespace....
Well, maybe. I wouldn't really expect CharStream
to do such a transformation but on the other hand trailing whitespace is mostly meaningless so maybe it's better off that way anyway. I'd at least adjust the name in that case.
Recommend
-
67
Scott Hanselman on Programming, The Web, Open Source, .NET, The Cloud and More
-
3
A Recap of Request Handling in Go Last updated: 21st January 2018 Filed under: go...
-
12
Collaborator nyalldawson commented
-
11
How to delete the carriage return / line feed from CSV - EXCEPT at the end of each line? advertisements Is it possible using a batch file or p...
-
9
Troubleshoot New Line Breaks, Line Feeds and Carriage Returns in SSIS Flat File Destination By: Kenneth A. Omorodion | Updated: 2021-05-24 |
-
4
Ethereum Now Handling Fifty Times More Than Bitcoin in Network Fees – Trustnodes Ethereum Now Handling Fifty Times More Than Bitcoin in Network Fees – Trustnodes Ethereum is currently 50x more in demand than bitcoin based on t...
-
7
[C] Remove String Trailing Newline (Carriage Return) January 09, 2013 The follo...
-
9
What is a carriage dispute and why does YouTube TV keep getting embroiled in them? By Alessandro Mascellino Published 51 minute...
-
7
Rajesh Subbaiah November 15, 2022 2 minute read...
-
5
回忆上次内容进程前后台切换 <kbd>ctrl</kbd> + <kbd>z</kbd> 把当前进程切换到后台并暂停jobs 查看所有作业用 fg 可以把后台进程再切回前台...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK