[ nice-Bugs-749019 ] EnsureTypeProc has wrong type

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.lang.nice.devel
Message-ID <[email protected]>
Bugs item #749019, was opened at 2003-06-04 19:19
Message generated for change (Comment added) made by bonniot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=749019&group_id=12788

Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Bryn Keller (xoltar)
>Assigned to: Daniel Bonniot (bonniot)
Summary: EnsureTypeProc has wrong type

Initial Comment:
Apologies for the long code sample - this code compiles
fine with the development version, but when run gives
this error:


[brk@brk brk]$ java -Dassertions=true -jar test.jar
Exception in thread "main"
nice.tools.code.EnsureTypeProc has wrong type
([Ljava.lang.Object;)
        at gnu.mapping.WrongType.make(WrongType.java:56)
        at test.fun.main(./test:90)

the line referenced in the stack trace is the
while(it.hasNext()) line.

void main(String[] args)
{
  
  let List<String> pos = ["1", "2", "3", "4"];
  let List<String> neg = ["-1", "-2", "-3", "-4"];
  let Iterator<(String,String)> it = zip(pos.iterator,
neg.iterator);
  while(it.hasNext()) {
    (String left, String right) = it.next();
  }
}

/**
 * Takes two iterators, and returns a new iterator
which yields
 * tuples made of one element from the first iterator,
and one
 * from the second.
 */
<T,U> Iterator<(T,U)> zip(Iterator<T> one, Iterator<U>
two);

<T,U>zip(one@Iterator, two@Iterator) = iterator(() => 
  {  
    if (one.hasNext() && two.hasNext()) {    
      let T oneItem = one.next;
      let U twoItem = two.next;
      return (oneItem, twoItem);
    }
    throw new NoSuchElementException();
  });

/**
 * Treat any ()->T function as an Iterator&lt;T&gt;.
The function
 * should raise NoSuchElementException if it can't
produce any
 * more elements.
 * 
 * Example:
 * <pre>
 * var byte counter = 0;

 * //A silly iterator from 0 to 9
 * let Iterator<byte> it = iterator(()=> {
 *    if (counter > 9)
 *       throw new NoSuchElementException();
 *    else
 *       return counter++;
 * }
 * </pre>
 */
<T> Iterator<T> iterator(()->T func) = new
FunctionIterator(function: func);

/**
 * Private. Used in iterator(()->T).
 */
class FunctionIterator<T> implements Iterator<T> 
{
  ()->T function;
  /* internal */ ?T current = null;

  private boolean fetch() 
    {
      try 
      {
	T val = (this.function)();
	current = val.cast();
	return true;
      } 
      catch (NoSuchElementException e) 
      {
	current = null;
	function = () => { throw new
UnsupportedOperationException(); };
	return false;
      }
  }

  hasNext() = current != null || this.fetch();

  <T>next() 
    {
      if (this.current != null || this.fetch()) 
	{
          let item = this.current;
	  if (item != null) 
	    {
	      this.current = null;
	      return item.cast();
	    }
	} 
      throw new NoSuchElementException();
    }

  remove() { throw new UnsupportedOperationException();
}      
}


----------------------------------------------------------------------

>Comment By: Daniel Bonniot (bonniot)
Date: 2003-11-27 12:58

Message:
Logged In: YES 
user_id=88952

This is now fixed in CVS and in the development compiler.
Sorry for the delay in fixing. 

----------------------------------------------------------------------

Comment By: Arjan Boeijink (arjanb)
Date: 2003-06-04 20:20

Message:
Logged In: YES 
user_id=688815

A simplification of this testcase:

<T,U> (T,U) foo(T x, U y) = (x,y); 

void main(String[] args) {
(String fst, String snd) = foo("abc","zyx");
}


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=749019&group_id=12788


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.