Open iacore opened 3 years ago
To reproduce it, simply replace the above function in test/api/api_tests.c
and run:
> bin/wren_test test/api/foreign_class.wren
fish: Job 1, 'bin/wren_test test/api/foreign_…' terminated by signal SIGSEGV (Address boundary error)
Should trigger an error/assert in debug mode.
Should trigger an error/assert in debug mode.
I simply ran make
to build the static library.
Anyway, I think { NULL, _ }
should mean no foreign class is found. The current behavior is inconsistent with bindForeignMethodFn
, where returning NULL means no method is found and raise an error.
Possible duplicate of #811
Should trigger an error/assert in debug mode.
foreign class A { construct new() {} }
var a = A.new()
![image](https://user-images.githubusercontent.com/14926524/132105810-5a3e55aa-8191-46f6-9f32-52d25a781b80.png)
Currently, when the bind foreign class callback returns
{ NULL, NULL }
like the following:Any attempt to create a class in Wren will result in segmentation fault.
In https://wren.io/embedding/storing-c-data.html, the code example given does just that.
I think Wren should throw an error about foreign class not defined when
allocateFn
is NULL.I also suspect that Wren might crash when a foreign class's
finalizeFn
is NULL, but I haven't tried that.