waneck / testrepo

0 stars 0 forks source link

Issue 1812 - Compiler error "field iterator is not a method" if iterator() method has optional arguments. - haxe #1812

Closed waneck closed 11 years ago

waneck commented 11 years ago

[Google Issue #1812 : http://code.google.com/haxe/issues/detail?id=1812] by P.Svil...@gmail.com, at 2013-05-12T13:06:40.000Z What steps will reproduce the problem? 1.Create a class with iterator() method containing 1 or more optional arguments, and returning a new object of a different class as the iterator. 2.Compile. 3.???? 4.Error.

What is the expected output? What do you see instead? Either have it work as a regular iterator() call, or provide a more detailed error about the iterator method. Instead, this error is thrown: "The field iterator is not a method"

Please complete the following class with minimal code reproducing the problem :

class Test { var i:Int; public function new() { i = 0; } public function iterator( start:Int = 0):Iterator<Int> { return new TestIterator( start); } static function main() { var t = new Test(); for ( i in t) trace( i); } } class TestIterator { var s:Int; public function new( start:Int) { s = start; } public function hasNext():Bool { return s < 100; } public function next():Int { return s++; } }

Please provide any additional information below. The iterator() method with optional arguments works if the same object that the iterator method was called on is returned: public function iterator( start:Int = 0):Iterator<Int> { return this; } As soon as a different object is used as the iterator, the compiler throws the error mentioned previously.

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-05-12T13:16:12.000Z] This issue was closed by revision r6627.