Open
Description
Describe the bug
Evaluating a function-type constructor keyword argument causes null-pointer exception.
To Reproduce
Steps to reproduce the behavior:
import IO;
int fallBackF(int i) {
return i;
}
data A
= a(int(int) f = fallBackF)
| b(int(int) f = int(int i) { return i * 2; })
;
// NPE
test bool kwDefault() {
A aa = a();
return aa.f(1) == 1;
}
// NPE
test bool inlineKwDefault() {
A bb = b();
return bb.f(1) == 2;
}
Workaround: using common keyword arguments (on the ADT instead of constructor) works:
data B(int(int) g = fallBackF, int(int) h = int(int i) { return i * 2; })
= c()
;
// Succeeds
test bool commonKwDefault() {
B aa = c();
return aa.g(1) == 1;
}
// Succeeds
test bool inlineCommonKwDefault() {
B aa = c();
return aa.h(1) == 2;
}
Expected behavior
Definitely no NPE. All tests should succeed.
Activity