closure-library icon indicating copy to clipboard operation
closure-library copied to clipboard

Report a small bug, and a small fix: False alarm "could not determine the type of this expression"

Open gilad-bendor opened this issue 8 years ago • 2 comments

Hello, I encountered this annoying bug many times - the bug can be demonstrated by compiling this code:

(function(){
    /** @constructor */
    function MyClass() {}
    /** @type {!string} */ MyClass.prototype.myProp;
    /** @type {!MyClass} */({}).myProp;                            <== Error: "could not determine the type of this expression"
})();

After long deep effort, it seems that this can be fixed by adding one line to com.google.javascript.jscomp.TypeInference: Add this line: objType.resolve(registry.getErrorReporter(), scope); right after this line: if (propertyType == null && objType != null) { in the method private JSType getPropertyType(JSType objType, String propName, Node n, FlowScope scope) {...}

gilad-bendor avatar Mar 22 '16 20:03 gilad-bendor

This is something related to the Closure Compiler, not Closure Library. Can you report to https://github.com/google/closure-compiler instead? Thanks!

Dominator008 avatar Mar 22 '16 21:03 Dominator008

body p { margin-bottom: 0cm; margin-top: 0pt; } 


Done - thanks  :-)

On 22-Mar-16 23:04, Michael Zhou wrote:


  This is something related to the Closure Compiler, not Closure
    Library. Can you report to https://github.com/google/closure-compiler
    instead? Thanks!
  —
    You are receiving this because you authored the thread.
    Reply to this email directly or view
      it on GitHub

gilad-bendor avatar Mar 23 '16 11:03 gilad-bendor