brownplt / pyret-lang

The Pyret language.
Other
1.06k stars 106 forks source link

Nearly Useless Error Message when Compiling JS Module #1325

Open SethPoulsen opened 6 years ago

SethPoulsen commented 6 years ago

If I try to run a Pyret program that uses a module written in Javascript, and the Javascript module tries to use an npm module that is not found, I get the following error:

 TypeError: Cannot read property 'brands' of undefined
    at hasBrand (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:208987:26)
    at PFunction.app (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:209003:30)
    at PFunction.isExit [as app] (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:226196:36)
    at Object.maybeMethodCall1 (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:208397:22)
    at PFunction._b24b56738cdb3f545b05f4ce5bae52391c6e2b2f12c3e27040742cc6a333d1e9__299 [as app] (eval at thisRuntime.safeCall.realm.(anonymous function) (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:212732:32), <anonymous>:3341:13)
    at ActivationRecord._b24b56738cdb3f545b05f4ce5bae52391c6e2b2f12c3e27040742cc6a333d1e9__311 [as fun] (eval at thisRuntime.safeCall.realm.(anonymous function) (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:212732:32), <anonymous>:3531:34)
    at Immediate.iter [as _onImmediate] (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:211082:28)
    at runCallback (timers.js:763:18)
    at tryOnImmediate (timers.js:734:5)
    at processImmediate (timers.js:716:5)
Stack trace:
 TypeError: Cannot read property 'brands' of undefined
    at hasBrand (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:208987:26)
    at PFunction.app (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:209003:30)
    at PFunction.isExit [as app] (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:226196:36)
    at Object.maybeMethodCall1 (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:208397:22)
    at PFunction._b24b56738cdb3f545b05f4ce5bae52391c6e2b2f12c3e27040742cc6a333d1e9__299 [as app] (eval at thisRuntime.safeCall.realm.(anonymous function) (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:212732:32), <anonymous>:3341:13)
    at ActivationRecord._b24b56738cdb3f545b05f4ce5bae52391c6e2b2f12c3e27040742cc6a333d1e9__311 [as fun] (eval at thisRuntime.safeCall.realm.(anonymous function) (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:212732:32), <anonymous>:3531:34)
    at Immediate.iter [as _onImmediate] (/Users/seth/pyret/pyret-lang/build/phaseA/pyret.jarr:211082:28)
    at runCallback (timers.js:763:18)
    at tryOnImmediate (timers.js:734:5)
    at processImmediate (timers.js:716:5)

I enjoyed learning more about the compiler while digging in to figure out what was going on, but it might be nice to have a more informative message.

sorawee commented 6 years ago

Tell me about it...