Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when calling redef on a variable without a value #467

Open
timwoj opened this issue Jul 12, 2019 · 1 comment

Comments

@timwoj
Copy link
Contributor

commented Jul 12, 2019

From #157 (comment):

An example similar to what's in the original report does segfault:

global a: count &add_func = function(): count { return 3; };
redef a += 13;
print a;

Could either fix that as part of this issue or separately, since not sure it's just type-checking problem or a problem with redefing something that has no initial value (or combination). E.g. this one gives a "argument type mismatch error":

global a: count = 1 &add_func = function(): count { return 3; };
redef a += 13;
print a;

Which seems like the right behavior (except maybe message could be more descriptive) because the actual function should be:

global a: count = 1 &add_func = function(old: count, new: count): count { return 3; };
redef a += 13;
print a;
@0xxon

This comment has been minimized.

Copy link
Member

commented Jul 12, 2019

There seem to be two things here.

Redef-ing a variable without an initial value actually seems like it should be fine - when the redef just does a normal assignment. +=, etc obviously cannot work.

An &add_func only seems to make sense when there is an initial value - otherwise there is no "old".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.