flow icon indicating copy to clipboard operation
flow copied to clipboard

Type argument can't be referenced inside function

Open samwgoldman opened this issue 11 years ago • 5 comments

I believe this is a known issue, but I couldn't find an existing issue for it.

/* @flow */

var constant = function<U>(u: U) {
  return function(): U {
    return u;
  }
}

Results in:

test.js|4 col 22 error|  identifier U
|| Unknown global name
|| 

samwgoldman avatar Feb 26 '15 23:02 samwgoldman

FWIW, this does work:

/* @flow */

type Constant<T> = () => T;

function constant<T>(x: T): Constant<T> {
  return function() {
    return x;
  }
}

samwgoldman avatar Feb 27 '15 01:02 samwgoldman

Definitely a known issue. :) Thanks!

bhosmer avatar Mar 03 '15 02:03 bhosmer

Looks like this is fixed in 0.5.0

samwgoldman avatar Mar 07 '15 00:03 samwgoldman

I lied. Still broken in 0.5.0

samwgoldman avatar Mar 07 '15 01:03 samwgoldman

This is a duplicate of #160

samwgoldman avatar May 15 '15 22:05 samwgoldman