Skip to content
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

nativecall sub declaration complains about 'returns' type when type has been predeclared using yadda-yadda on Rakudo Moar #3529

Open
p6rt opened this issue Sep 20, 2014 · 3 comments
Labels

Comments

@p6rt
Copy link

@p6rt p6rt commented Sep 20, 2014

Migrated from rt.perl.org#122815 (status was 'open')

Searchable as RT122815$

@p6rt
Copy link
Author

@p6rt p6rt commented Sep 20, 2014

From anteusz@freemail.hu

HI ALl,

1.
  use NativeCall;
2.
3.
  class TopWindow {...}
4.
5.
  class TopWindow is repr('CPointer') is export {
6.
7.
  sub TopWindow_TopWindow_c() returns TopWindow is
  symbol('TopWindow_TopWindow_c') is native("whatever") { * }
8.
9.
  multi method new() returns TopWindow {
10.
  return TopWindow_TopWindow_c();}
11.
12.
  }
13.
14.
15.
  my $t = TopWindow.new();

if I run this,
I get
Unknown type TopWindow used in native call.
If you want to pass a struct, be sure to use the CStruct representation.
If you want to pass an array, be sure to use the CArray type.
  in sub type_code_for at
D​:\rakudogit\install/languages/perl6/lib\NativeCall.pm6​:89
  in sub return_hash_for at
D​:\rakudogit\install/languages/perl6/lib\NativeCall.pm6​:62
  in method postcircumfix​:<( )> at
D​:\rakudogit\install/languages/perl6/lib\NativeCall.pm6​:127
  in method new at D​:\m\perl\cheadertoperl6\test.p6​:9
  in block <unit> at D​:\m\perl\cheadertoperl6\test.p6​:15

if you remove class TopWindow {...}, it starts working.

I need to forward reference TopWindow as it is used in other classes,
function calls.

And other may need it too "en el futuro"

Marton

Loading

@p6rt
Copy link
Author

@p6rt p6rt commented May 8, 2018

From @skids

Golf and change of behavior​:

$ perl6 -e 'use NativeCall; class T is repr<CPointer> is export { sub new(size_t $n) returns T is symbol<malloc> is native { * }; }; T.new();'
$ perl6 -e 'use NativeCall; class T {...}; class T is repr<CPointer> is export { sub new(size_t $n) returns T is symbol<malloc> is native { * }; }; T.new();'
===SORRY!=== Error while compiling -e
Cannot change REPR of T now (must be set at initial declaration)
at -e​:1

Workaround​:

$ perl6 -e 'use NativeCall; class T is repr<CPointer> {...}; class T is export { sub new(size_t $n) returns T is symbol<malloc> is native { * }; }; T.new(); say T.REPR;'
CPointer

Loading

@p6rt
Copy link
Author

@p6rt p6rt commented May 8, 2018

The RT System itself - Status changed from 'new' to 'open'

Loading

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant