Skip to content

Scanner does not properly track line starts for multi-line raw strings #22794

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

Closed
pq opened this issue Mar 11, 2015 · 5 comments
Closed

Scanner does not properly track line starts for multi-line raw strings #22794

pq opened this issue Mar 11, 2015 · 5 comments
Assignees
Labels
legacy-area-analyzer Use area-devexp instead. P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@pq
Copy link
Member

pq commented Mar 11, 2015

Analyzing source:

var a = r'''
blah
''';

b = 1;

yields:

src/scratch.dart 4:1 [syntactic error] Variables must be declared using the keywords 'const', 'final', 'var' or a type name

Net-net the line number should be 5.

I confirmed that making this a non-raw string fixes the line number.

@pq
Copy link
Member Author

pq commented Mar 11, 2015

To be more precise, here's the actual output:

[error] Variables must be declared using the keywords 'const', 'final', 'var' or a type name (.../lib/src/scratch.dart, line 4, col 1)

@pq
Copy link
Member Author

pq commented Mar 11, 2015

Related linter issue: #57196

For now I've worked around it but that's not ideal for all the obvious reasons.

@bwilkerson
Copy link
Member

I think the following test will catch the problem:

  void test_lineInfo_multilineString_raw() {
    String source = "var a = r'''\nblah\n''';\n\nfoo";
    _assertLineInfo(source, [
      new ScannerTest_ExpectedLocation(0, 1, 1),
      new ScannerTest_ExpectedLocation(14, 2, 2),
      new ScannerTest_ExpectedLocation(source.length - 1, 5, 2)
    ]);
  }


Added this to the 1.10 milestone.
Removed Priority-Unassigned label.
Added Priority-High label.

@bwilkerson
Copy link
Member

Set owner to @bwilkerson.
Added Started label.

@bwilkerson
Copy link
Member

https://codereview.chromium.org/1000913004/ (bleeding edge revision 44481)


Added Fixed label.

@pq pq added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures legacy-area-analyzer Use area-devexp instead. labels Mar 13, 2015
@pq pq added this to the 1.10 milestone Mar 13, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

2 participants