blickly / closure-compiler-issues

0 stars 0 forks source link

[Doc fix] Function type expressions documented as never nullable, however compiler supports nullable functions. #100

Closed blickly closed 9 years ago

blickly commented 9 years ago
What steps will reproduce the problem?

/** @param {?function(*=)} fn
 */
function func(fn)
{
    if(fn)
    {
        fn();
    }
};

func(function() {});
func(null);

/** @param {function(*=)} fn
 */
function func2(fn)
{
    if(fn)
    {
        fn();
    }
};

func2(function() {});
func2(null);

1. Compile above with verbose warnings.
2. Notice compiler behaves as if functions are nullable, ie. does not
complain about func's type expression or the call to func(null). 
3. Conclude nullable functions are supported.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

HEAD

Please provide any additional information below.

In http://code.google.com/closure/compiler/docs/js-for-compiler.html ,
remove the statement "Function types are never nullable."

Nullable functions are useful, and required to properly annotate existing
code I am working with.

Original issue reported on code.google.com by meepmeepmeepenator on 2010-02-02 23:10:36

blickly commented 9 years ago
Yes, the doc should be fixed.  "Function" is nullable by default, and "function" is
not but can be if "?" is used.  Just as "Boolean", "Number", and "String" are
nullable object types, and "boolean", "number", and "string" are not.

Original issue reported on code.google.com by concavelenz on 2010-03-18 00:46:10

blickly commented 9 years ago
(No text was entered with this change)

Original issue reported on code.google.com by concavelenz on 2010-03-27 00:12:44