-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fix #48 #49
Fix #48 #49
Conversation
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
|
I also just tested the code, it is a compiler error. |
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 😁 |
Not a minimal code, but I get the crash doing: |
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 crystal-lang/crystal#12894 gets fixed and released. |
GitHub closed this one because I removed the |
Closes #48
This seems to fix the issue.
Newly generated code: