Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/scanner: literal too long for non-terminated strings #7091

Closed
griesemer opened this issue Jan 10, 2014 · 1 comment
Closed

go/scanner: literal too long for non-terminated strings #7091

griesemer opened this issue Jan 10, 2014 · 1 comment

Comments

@griesemer
Copy link
Contributor

For non-terminated strings (and characters), the scanner returns a literal that is
longer (by one character) than is necessary. Example:

$ cat x.go
package p

import (
    "foo
)

$ gotype -trace x.go
    1:  1: File (
    1:  1: . "package"
    1:  9: . IDENT p
    1: 10: . ";"
    3:  1: . GenDecl(import) (
    3:  1: . . "import"
    3:  8: . . "("
    4:  2: . . ImportSpec (
    4:  2: . . . STRING "foo
)
    5:  2: . . . ";"
    5:  3: . . )
    5:  3: . . EOF
    5:  3: . )
    5:  3: )
x.go:4:2: string not terminated
x.go:5:3: expected ')', found 'EOF'

The reported literal value for the non-terminated string "foo is
"\"foo\n)" rather than just  "\"foo\n" (extra ) at end).
This can lead to worse parser token synchronization in error situations than necessary.
@griesemer
Copy link
Contributor Author

Comment 1:

This issue was closed by revision 11740e1.

Status changed to Fixed.

@griesemer griesemer self-assigned this Jan 13, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants