numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
200 stars 117 forks source link

Nested randoms #243

Closed BillFoster closed 11 years ago

BillFoster commented 11 years ago

get NaN if , for example evaluate random(random([1,2],[2,3])). However if we set variable a=random([1,2],[2,3]) then random(a) is OK See https://numbas-editor.mas.ncl.ac.uk/question/603/testran/

christianp commented 11 years ago

Yep, this is a pretty major bug in the way I do type analysis (i.e., I don't really). When it can't decide the type of a function's output, it matches it as "any", so the the first definition of the outer function is used. In this case, it's the version of random() that works on ranges instead of lists, so we get NaN.

I need to do some proper thinking about what to change to fix this.