gosu-lang icon indicating copy to clipboard operation
gosu-lang copied to clipboard

Gosu compiler doesn't report an error if static imports are ambiguous

Open vrumiantcev opened this issue 7 years ago • 2 comments

uses SomeClass#foo(String)
uses SomeOtherClass#foo(String)

class Test {
  public function f() {
    foo("hi")
  }
}

Gosu executes the method from SomeClass.

Expected behavior: Gosu reports an error when trying to run the method.

vrumiantcev avatar Jun 07 '17 21:06 vrumiantcev

Also if a class declares a method and statically imports another method with the same name, Gosu resolve the method call to the method that was imported. This seems wrong too.

class Test2 {
  static function f():String {
    return "from Test2"
  }
}
uses Test2#f()

class Test {
  static function f():String {
    return "from Test"
  }
  
  static function test() {
    print(f()) // prints "from Test2"
  }
}

vrumiantcev avatar Jun 21 '17 18:06 vrumiantcev

Expected behavior: Gosu reports an error when trying to run the method.

I'd argue that it should be a compiler error rather than a run-time error.

tredontho avatar Feb 23 '18 15:02 tredontho