Skip to content

//line directive does not support source file names containing colons #2543

@gopherbot

Description

@gopherbot

by jmillikin:

The //line directive used for altering error location strings is not parsed properly by
the Go compiler, if the filename it sets contains colons.

Given an original file named "support/lang:go.def", which is processed to
generate a Go source file, an example // line directive would be:

//line support/lang:go.def:1

Which cannot be parsed.

Three proposed solutions:

1. Introduce an escape character, such as \, so that colons in the filename may be
escaped.

2. Use full string literal syntax for the filename, similar to C's #line directive. This
would include escape characters as above.

3. Read the lexbuf until EOF. Split on position of the last colon found. Everything
before the last colon is the filename, anything after is the line.

#3 seems like the easiest and safest to implement, because the only cases where it
changes the behavior are currently invalid anyway.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions