Closed jvasileff closed 9 years ago
Generated code:
var $2=m$1.tpl$([0]);
var $3;
m$1.asrt$((function($4){if(!m$1.nn$($4))return false;return($3=$4.$_get(0));}($2)),"Assertion failed: \'exists [i] = ti\' at run.ceylon (3:11-3:27)",'3:4-3:28','run.ceylon');
m$1
is the language module. asrt$
is defined in runtime-js/core_functions.js
:
//for shorter assert
function asrt$(cond,msg,loc,file) {
if (!cond)throw wrapexc(AssertionError(msg),loc,file);
}
Since 0
is falseish, !cond
is true, and the assertion is thrown. I think the inline function should instead be
function($4){if(!m$1.nn$($4))return false;$3=$4.$_get(0);return true;}
Yeah, if I understand those hieroglyphics, example2
should be tested, but not its contents. So, this should also work:
Integer?[4]? example2 = [1,2,3,null];
assert (exists [e,f,g,h] = example2);
assert (!exists h);
and the funny part is, this only happens when the last element is 0
; if any other element is 0
it works fine.
I imagine it also happens for [true,true,false]
, no?
probably, yeah.
This might be the shortest modification I've ever made to fix a bug
Nice :D You’ve never had to turn a ==
into a ===
?
not for a bugfix... this could have been a ,1
btw but I prefer to keep it cleaner with true
.
For example: