Error computing referenced variable c

Skip to first unread message

William Haynes

Sep 12, 2021, 10:11:34 PMSep 12
to Numbas Users

Could you look at this question,  because I think I have uncovered a bug.  

I have defined a JME extension function loc(A,B,C)  -- to solve the law of cosines for the the angle opposite side A.

I use it three times to find the angles of a triangle with sides A, B and R.

thetaA = LOC(A,B,R)
thetaB = LOC(B,A,R)
thetaR = LOC(R,A,B)

All three produce "Error computing referenced variable c".

If I define a dummy variable C it eliminates the error, but I don't think I should have to since the names of the parameters should be immaterial. I just noticed this problem.  I don't believe it happened when I wrote the question three years ago.


Christian Lawson-Perfect

Sep 13, 2021, 3:47:39 AMSep 13
Hi Will,
Yes, that's a bug - thanks for telling me! When working out what variables a custom function depends on, it looks at the list of parameters you've defined, and then the expression for the body of the function. The routine to find variables in the body normalises names, but the names of the parameters weren't normalised. Because you put your parameter names in capitals, it thought that lower-case 'c' was an external variable. 'a' and 'b' were OK because you've defined question variables 'A' and 'B', which are also normalised properly.
I've fixed this, and it looks like your question works now.

You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web, visit
Reply all
Reply to author
0 new messages