develooper Front page | perl.perl5.porters | Postings from April 2016

Re: [perl #127993] Version control conflict markers

Thread Previous | Thread Next
From:
Kent Fredric
Date:
April 26, 2016 09:01
Subject:
Re: [perl #127993] Version control conflict markers
Message ID:
CAATnKFC5MiHk8K8NBCNEK4q-Y5bccrup0GTPndTDyGu3yASnbg@mail.gmail.com
On 26 April 2016 at 19:04, Ed Avis <perlbug-followup@perl.org> wrote:
>
> Sometimes Perl code will appear to compile when there are git conflict
> markers like <<<<<<< in the file.  Or sometimes it gives an error but
> one that doesn't make it clear what the problem really is.
>
> I suggest adding explict detection of <<<<<<< ======= >>>>>>> as
> tokens and making them give an immediate error which stops parsing.
> As usual, this would not catch 100% of all such errors (the conflict
> markers might be inside a here-document, and so on) but it would
> be a great help nonetheless.
>
> For C and C++ programs, the latest gcc now reports
>    test.c:3:1: error: version control conflict marker in file
> It would be great for perl's error reporting to be as good as C.

A CPAN Grep says there's not a lot of risk for a mistake here, a
non-anchored result turns up a few entries, mostly, other code
checking for conflict markers.

<{5,90}.{0,500}={5,90}

http://grep.cpan.me/?q=%3C{5%2C90}.{0%2C500}%3D{5%2C90}

An Anchored CPAN Grep returns no results, suggesting its probably safe:


^<{5,90}.{0,500}^={5,90}

http://grep.cpan.me/?q=^%3C{5%2C90}.{0%2C500}^%3D{5%2C90}

Obviously, C has the Luxury that it doesn't have heredocs.

But fortunately for us,

 <<<<<<

Is parsed as

<<"" <<"" <<""

Not

<<"<<<<"

So there's no risk of it being some weird heredoc side-effect either,
and we deprecated <<"" already :D  ( See attached hereconflict.pl )

The only thing I'd want to make sure of is how we handled embedded git
conflict markers /inside string literals/ are handled right, because
you never know, there's probably some legitimate usecase for embedding
a conflict inside a heredoc. ( See attached hereconflict2.pl )






-- 
Kent

KENTNL - https://metacpan.org/author/KENTNL

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About