mirror of
https://github.com/vlang/v.git
synced 2025-09-16 16:02:29 +03:00
compiler: let methods return voidptr without a segfault
This commit is contained in:
parent
7d763e0776
commit
fce4199412
2 changed files with 30 additions and 3 deletions
|
@ -238,9 +238,13 @@ fn (p mut Parser) gen_method_call(receiver_type, ftyp string, cgen_name string,
|
|||
// Method returns (void*) => cast it to int, string, user etc
|
||||
// number := *(int*)numbers.first()
|
||||
if ftyp == 'void*' {
|
||||
// array_int => int
|
||||
cast = receiver_type.all_after('_')
|
||||
cast = '*($cast*) '
|
||||
if receiver_type.starts_with('array_') {
|
||||
// array_int => int
|
||||
cast = receiver_type.all_after('_')
|
||||
cast = '*($cast*) '
|
||||
}else{
|
||||
cast = '(voidptr) '
|
||||
}
|
||||
}
|
||||
p.cgen.set_placeholder(method_ph, '$cast $method_call')
|
||||
//return method_call
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue