Skip to content

[VM] Possibly incorrect error message when explicitly using this in a constructor initializer #3185

Closed
@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


Code:
class C {
  C() : v = this.f {}
  var v;
  final f = 1;
}

The compile-time error I see on VM is:

unexpected use of 'this' in primary expression
  C() : v = this.f {}
            ^
According to spec, the initializer requires a conditionalExpression argument, which can be reduced to a postfixExpression of the form primary.identifier and this.f perfectly matches this production.
When an unqualified invocation/field access is used, the error is about illegal access to 'this', and it should probably be the same error in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions