Skip to content

Lookup for unqualified variable should look up in library and static scope before 'this' #2116

@DartBot

Description

@DartBot

This issue was originally filed by zundel@google.com


This is meant to exercise the scope rules of 10.28 for unqualified identifier lookup. Currently there is a discrepancy between frog & vm implementation. I believe this is a bug in the VM - I looked for as similar language test and couldn't find one.

class A {}
class B {}

A get foo() {
   return new A();
}

class C {
  B get foo() {
    return new B();
  }
  testGetter() {
    return foo; // lexically closest def is in this class.
  }
}

class D extends C {
  testGetter() {
    return foo; // lookup rules in 10.28 favor top level scope over this.foo
  }
}

main() {
  var result;
  result = new C().testGetter();
  Expect.isTrue(result is B);
  result = new D().testGetter();
  Expect.isTrue(result is A); // vm fails here
}

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