Fix #48
Closes #48
This seems to fix the issue. Newly generated code:
# Prototype of the function called to create new child models when
# gtk_tree_list_row_set_expanded() is called.
#
# This function can return %NULL to indicate that @item is guaranteed to be
# a leaf node and will never have children. If it does not have children but
# may get children later, it should return an empty model that is filled once
# children arrive.
alias TreeListModelCreateModelFunc = Proc(GObject::Object, Gio::ListModel?)
nice, I’ll add a test before merge in the next few days when I sit down in front of a computer again.
Interesting... adding just:
--- a/spec/libtest/test_subject.h
+++ b/spec/libtest/test_subject.h
@@ -66,6 +66,17 @@ typedef struct _TestSubjectClass {
*/
typedef void (*TestSubjectSimpleFunc)(TestSubject* subject, int number, gpointer user_data);
+/**
+ * TestSubjectCallbackReturningNullFunc:
+ * @subject: The subject
+ * @obj: An object
+ * @user_data:
+ *
+ * Used to test callback code generation with nullable return type.
+ *
+ * Returns: (nullable) (transfer full): A nullable object
+ */
+typedef TestSubject* (*TestSubjectCallbackReturningNullFunc)(TestSubject* subject, TestSubject* obj, gpointer user_data);
+
/**
* test_subject_new_from_whatever:
* @value:
that correctly generates:
# Used to test callback code generation with nullable return type.
alias SubjectCallbackReturningNullFunc = Proc(Test::Subject, Test::Subject, Test::Subject?)
Crashes the compiler on make test, or at least I think it's the compiler, since the crash pass through libLLVM-13.
Invalid memory access (signal 11) at address 0x0
[0x55fed15ae5f6] ?? +94552922449398 in crystal
[0x55fed15ae5c1] ?? +94552922449345 in crystal
[0x7f3c3123e8e0] ?? +139896499202272 in /usr/lib/libc.so.6
[0x7f3c32762f08] _ZN4llvm11PointerType3getEPNS_4TypeEj +24 in /usr/lib/libLLVM-13.so
[0x7f3c3263391f] LLVMBuildInBoundsGEP +287 in /usr/lib/libLLVM-13.so
[0x55fed124f05d] ?? +94552918913117 in crystal
[0x55fed1259adb] ?? +94552918956763 in crystal
[0x55fed12670bd] ?? +94552919011517 in crystal
[0x55fed1266ead] ?? +94552919010989 in crystal
[0x55fed1264e1c] ?? +94552919002652 in crystal
[0x55fed12a960a] ?? +94552919283210 in crystal
[0x55fed126e6a4] ?? +94552919041700 in crystal
[0x55fed128228f] ?? +94552919122575 in crystal
[0x55fed126ff5d] ?? +94552919048029 in crystal
[0x55fed129078e] ?? +94552919181198 in crystal
[0x55fed127103b] ?? +94552919052347 in crystal
[0x55fed126e748] ?? +94552919041864 in crystal
[0x55fed128228f] ?? +94552919122575 in crystal
[0x55fed126ff5d] ?? +94552919048029 in crystal
[0x55fed129078e] ?? +94552919181198 in crystal
[0x55fed127103b] ?? +94552919052347 in crystal
[0x55fed126e748] ?? +94552919041864 in crystal
[0x55fed128228f] ?? +94552919122575 in crystal
[0x55fed126ff5d] ?? +94552919048029 in crystal
[0x55fed129078e] ?? +94552919181198 in crystal
[0x55fed127103b] ?? +94552919052347 in crystal
[0x55fed126fae2] ?? +94552919046882 in crystal
[0x55fed126eaf5] ?? +94552919042805 in crystal
[0x55fed126e748] ?? +94552919041864 in crystal
[0x55fed121a0b5] ?? +94552918696117 in crystal
[0x55fed15dfc7b] ?? +94552922651771 in crystal
[0x55fed1665fda] ?? +94552923201498 in crystal
[0x55fed0c792fb] __crystal_main +27403 in crystal
[0x55fed0c7e4ca] main +74 in crystal
[0x7f3c31229290] ?? +139896499114640 in /usr/lib/libc.so.6
[0x7f3c3122934a] __libc_start_main +138 in /usr/lib/libc.so.6
[0x55fed0c72715] _start +37 in crystal
[0x0] ???
I also just tested the code, it is a compiler error. It's probably a good idea to minimize it and send the bug report to crystal-lang.
This patch is fine, I'm just afraid of merge it right now and get bite by this compiler bug, so once I have more time I'll try to reduce this code to be able to file a bug report to crystal-lang.
The bug persists with crystal 1.6.2, I think now is time to try to reduce this compiler crash :grin:
Not a minimal code, but I get the crash doing:
./bin/spec spec/properties_spec.cr spec/signals_spec.cr
The compiler issue was reduced to:
class Foo
end
def crash(&block : Proc(Enumerable(Foo), Nil))
crash(block)
end
def crash(handler : Proc(Enumerable(Foo), Nil))
0
end
alias SubjectCallbackReturningNullFunc = Proc(Foo, Foo?)
foo = nil
crash do |bar|
foo = bar
end
Issue filed, this can be merged only when https://github.com/crystal-lang/crystal/issues/12894 gets fixed and released.
GitHub closed this one because I removed the master branch, since we already had some releases using main branch instead... and I'm not able to edit the PR.