[nem-bug] [Nemerle 0000643]: Error message for trying to use yield
in local functions
feedback at nemerle.org
feedback at nemerle.org
Sun May 13 16:41:51 CEST 2007
The following issue has been set as RELATED TO issue 0001015.
======================================================================
<http://nemerle.org/bugs/view.php?id=643>
======================================================================
Reported By: VladD2
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 643
Category: Compiler
Reproducibility: always
Severity: minor
Priority: normal
Status: confirmed
======================================================================
Date Submitted: 04-02-2006 19:16 CEST
Last Modified: 12-06-2006 19:11 CET
======================================================================
Summary: Error message for trying to use yield in local
functions
Description:
If try to implement the iterator as local function:
def FromTo(from : int, to : int) : IEnumerable[int]
{
for (mutable i = from; i <= to; ++i)
yield i;
}
ngg generate this error:
error : yield used in a function returning void (it should be
System.Collections.Generic.IEnumerator[T] or
System.Collections.Generic.IEnumerable[T])
error : yield used in a function returning void (it should be
System.Collections.Generic.IEnumerator[T] or
System.Collections.Generic.IEnumerable[T])
======================================================================
Relationships ID Summary
----------------------------------------------------------------------
related to 0001015 yield in local funs
======================================================================
----------------------------------------------------------------------
nazgul - 04-02-06 23:27
----------------------------------------------------------------------
I guess it is designed this way:
foo () : IEnumerable [int]
{
def several (x) {
yield x;
yield x + 1;
yield x + 3;
}
several (3);
seveal (100);
}
so you use local function just as an utility to make a generator from your
global function
----------------------------------------------------------------------
VladD2 - 04-03-06 15:09
----------------------------------------------------------------------
If local function cannot implement iterators by design, it's necessary to
write about this in docs and tutorials, and certainly correct the error
message, because error message "...in a function returning void" is
confusing.
----------------------------------------------------------------------
nazgul - 04-03-06 21:39
----------------------------------------------------------------------
I fixed the message.
But if the global method type is correct and you use yield insie local
function, then error message is even worse:
t.n:8:7:8:12: error: non local goto (block return?) detected (l1036)
t.n:5:8:5:28: error: non local goto (block return?) detected (l1027)
for
class A {
public foo () : IEnumerable [int]
{
def several (x) {
yield x;
yield x + 1;
yield x + 3;
}
several (3);
several (100);
}
}
----------------------------------------------------------------------
VladD2 - 04-03-06 23:28
----------------------------------------------------------------------
Hm... If I understand you correctly, you told about another situation.
I told about situation when programmer try to implement iterator directly
in the local function. i.e. in situation like this:
module App
{
Main() void
{
def F() : IEnumerable [int]
{
yield 1;
}
}
}
the user taken error message:
error : yield used in a function returning void (it should be
System.Collections.Generic.IEnumerator[T] or
System.Collections.Generic.IEnumerable[T])
he will be confused.
PS
BTW...How get SVN version of Nemerle?
----------------------------------------------------------------------
nazgul - 04-03-06 23:33
----------------------------------------------------------------------
This is now giving
t.n:7:6:7:11: error: yield used in a `Main' function, which is returning
void (it should be System.Collections.Generic.IEnumerator[T] or
System.Collections.Generic.IEnumerable[T])
To get svn version see:
http://nemerle.org/Hacking#The_repository
You can also get daily tarballs from:
http://nemerle.org/download/snapshots/
(they are generated at about 5am CET)
----------------------------------------------------------------------
VladD2 - 04-04-06 01:37
----------------------------------------------------------------------
> This is now giving
> t.n:7:6:7:11: error: yield used in a `Main' function, which is returning
> void (it should be System.Collections.Generic.IEnumerator[T] or
> System.Collections.Generic.IEnumerable[T])
Nice. :)
But would be better if would be the hint tell that it is impossible to
implement iterator as local function.
Issue History
Date Modified Username Field Change
======================================================================
04-02-06 19:16 VladD2 New Issue
04-02-06 23:27 nazgul Note Added: 0001140
04-03-06 15:09 VladD2 Note Added: 0001142
04-03-06 21:39 nazgul Note Added: 0001151
04-03-06 23:28 VladD2 Note Added: 0001156
04-03-06 23:33 nazgul Note Added: 0001157
04-04-06 01:37 VladD2 Note Added: 0001159
12-06-06 19:11 nazgul Status new => confirmed
12-06-06 19:11 nazgul Summary Iterator as local
fanction => Error message for trying to use yield in local functions
12-06-06 19:11 nazgul Description Updated
05-13-07 16:41 divan Relationship added related to 0001015
======================================================================
More information about the bugs
mailing list