Unexpected multi-line comment parsing feature with Go 1.8.3


Unexpected multi-line comment parsing feature with Go 1.8.3

When a string in a multi-line comment contains a */, it is interpreted as the comment end marker.

/* var s = "abc */ def" */ 

The compiler reports an error. Using back ticks yields the same result.

See http://ift.tt/2tRzzTq

This feature was a problem when trying to comment out regex expressions. They frequently contain */.

There is no such problem with the // comment. See http://ift.tt/2tnTqWZ

var s = "abc // def" 

This compiles without error. This is the behavior I would expect.

I don't see a use case for a multi-line comment ending in the middle of a string. These comments are usually used at instruction boundary.

What is your opinion about it ?

Submitted July 15, 2017 at 12:22AM by chmikes
via reddit http://ift.tt/2tRaSq2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s