Error computing referenced variable c

6 views
Skip to first unread message

William Haynes

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

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.

Will

Christian Lawson-Perfect

unread,
Sep 13, 2021, 3:47:39 AMSep 13
to numbas...@googlegroups.com
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 numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/90ea12e4-6fb9-4d9c-86dd-57d24ab328b9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages