Roslyn: Diagnostics positioned wrong in incremental parse.

Created on 21 Nov 2017  路  11Comments  路  Source: dotnet/roslyn

Version Used: Visual Studio 15.4.3

Steps to Reproduce:

Using this piece of code:

public async Task QueueFeedUpdate(Feed feed)
{
    string message = JsonConvert.SerializeObject(feed);
    if (CloudStorageAccount.TryParse(_connectionString, out CloudStorageAccount account))
    {
        var client = account.CreateCloudQueueClient();
        var queue = client.GetQueueReference("UpdateFeedItems");
        await queue.AddMessageAsync(new CloudQueueMessage(message));
    }
}
  1. Remove semicolon at line with the CloudQueueMessage (line 8)
  2. Squiggle is at end of line 8.
  3. Remove semicolon at line 3. Squiggle is at line 3.
  4. Add back the semicolon at line 3.

Expected Behavior:

Squiggle should go back to line 8 after the last )

image

Actual Behavior:

Squiggle goes to line 9 next to }.

image

Area-Compilers Bug Language-C# help wanted

Most helpful comment

@MaximRouiller I like red squiggles.

All 11 comments

The actual minimum reproducible code can be further reduced to this:

public void Test()
{
    var t = new object();
    var c = new object();
}
  1. Remove the semicolon at line 4. Squiggle at line 4.
  2. Remove/add the semicolon at line 3. Squiggle at line 5.

Fascinating. @gafter It looks like the IDE is just reporting the character given by the compiler (though i'm not 100% sure of that). Could this be an incremental bug?

Note: the easiest repro i have is as follows:

First, to see the expected case, just compile/paste the following code:

```c#
class C
{
public void Test()
{
var t = new object();
var c = new object()
}
}


Here, the error is correctly reported at the end of the second ```new object()```.   Now, to repro the bug, instead start with:

```c#
class C
{
        public void Test()
        {
            var t = new object()
            var c = new object()
        }
}

(note: no semicolons). There will be two errors, both after "new object()". Now type ; after the first "new object()". Instead of getting the errors from the expected case, the error is reported on the }.

Looks like an issue with the incremental parser.

w00t! I found an unreported bug! 馃槃

@gafter feel free to rename the issue to something more technical than red squiggles.

@MaximRouiller I like red squiggles.

w00t! I found an unreported bug! 馃槃

Congrats. I highly respect your ability to notice something so subtle!

@CyrusNajmabadi Yet my wife wonders how I can lose my keys in my house while I had them in my hands 5 minutes ago.

Where are the damn keys!?

Any progress on this? Can we close?

The bug still exists. It isn't serious, so I'm marking it as up-for-grabs.

Looks like the kind of bug that isn't serious enough to fix in a hurry yet would be hard to fix in a timely manner. 馃槀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AdamSpeight2008 picture AdamSpeight2008  路  3Comments

JesperTreetop picture JesperTreetop  路  3Comments

binki picture binki  路  3Comments

codingonHP picture codingonHP  路  3Comments

marler8997 picture marler8997  路  3Comments