Skip to content

Difference in output for DECLARES_INSTANCE_FIELD in extension and extension type #59847

@FMorschel

Description

@FMorschel

I was working on https://dart-review.googlesource.com/c/sdk/+/402622 (#59831) and I got to this code:

extension E on int {
  final int foo = 1, bar = 2;
}

Which has a similar case as:

extension type A(int i) {
  final int foo = 1, bar = 2;
}

But we have different outputs here:

To start, the error on extension type is a CompileTimeErrorCode and the error on extension is a ParserErrorCode. I'm unsure of what is the differentiation between them but I don't see any semantic differentiation here that would make them different.

But the problem I opened this to discuss is actually the following:

image

Why do we get more errors on one than on the other? That doesn't seem coherent to me.

CC @bwilkerson @scheglov @srawlins

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestlegacy-area-analyzerUse area-devexp instead.type-uxA user experience or user interface related issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions