On Sat, 16 Mar 2019, Artur Tarassow wrote:
Am 15.03.19 um 21:05 schrieb Cottrell, Allin:
> On Fri, Mar 15, 2019 at 4:01 PM Cottrell, Allin <cottrell(a)wfu.edu> wrote:
>>
>> Gretl shouldn't crash, but there's a rather obvious bug in your
>> code: you are assigning to self.fc from a function (meanf) that
>> doesn't return anything.
For some reason, I always think that I can simply attach new information
(scalar, matrix etc.) to an already existing bundle by defining something
like self.fc = foo without having to define what meanf() actually returns.
But this is my fault. Thanks for clarification. The "workaround" is totally
fine to me.
>> In general gretl should be be able to catch that bug. I guess
>> the problem in this case is that gretl has no means of knowing
>> what type of return value is wanted: "self.fc" carries no type
>> information.
>
> On experimentation, that's indeed the issue: if you do
>
> matrix self.fc = mean(&self)
>
> you get an error message and not a crash. Still, of course, the
> crash should not occur.
Thanks for figuring that out.
This is now fixed in git.
Just to be clear, it's OK to assign the return value from a function
without specifying a type on the left, as in
b.fc = meanf(&b)
in which case b.fc will have whatever type is returned by meanf().
An error -- now a proper flagged error, not a crash -- occurs only
if meanf() doesn't actually return anything (is of type "void").
Allin