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

Possible type signature bug #3783

Closed
p6rt opened this issue Apr 16, 2015 · 6 comments
Closed

Possible type signature bug #3783

p6rt opened this issue Apr 16, 2015 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Apr 16, 2015

Migrated from rt.perl.org#124317 (status was 'resolved')

Searchable as RT124317$

@p6rt
Copy link
Author

p6rt commented Apr 16, 2015

From @drforr

OS​: Ubuntu 14.10 LTS under VirtualBox
Host OS​: Windows 8, Intel Core I5

Rakudo version​: current as of 16/4/2015

The compiler complains of the following error​:

--cut here--
Calling rl_get_screen_size(Pointer, Pointer) will never work with
declared signature (Pointer, Pointer)
at /home/jgoff/Documents/perl6-readline/lib/ReadLine.pm6​:1153
------> ⏏rl_get_screen_size( $r, $c ) }
  from examples/perl6-echo.p6​:3
--cut here--

On the following code​:

--cut here--
  sub rl_get_screen_size( Pointer[Int], Pointer[Int] )
  is native( LIB ) { * }
  method rl-get-screen-size( Pointer[Int] $r, Pointer[Int] $c ) {
  rl_get_screen_size( $r, $c ) }
--cut here--

The problem seems to be directly related to the parametrization of the
Pointer type, signatures of the type 'rl_set_screen_size( Int, Int )'
aren't affected by this bug. Incidentally I'm aware that I could use "is
symbol('rl_get_screen_size')" but I've already had occasion to write
Perl6 code whose signature differs from the native code, so I'd rather
keep the flexibility around.

@p6rt
Copy link
Author

p6rt commented Apr 16, 2015

From @drforr

This is as minimal as I can get the test case​:

Error​: (notice the signatures do in fact match, in both error text and
code)

--cut here--
===SORRY!=== Error while compiling /home/jgoff/bug.t
Calling rl_get_screen_size(TypedPointer[Int], TypedPointer[Int]) will
never work with declared signature (TypedPointer[Int],
TypedPointer[Int])
at /home/jgoff/bug.t​:27
------> ⏏rl_get_screen_size( $r, $c ) }
--cut here--

The sample code is stolen directly from NativeCall.pm6 and ruthlessly
trimmed down, the 'class Bug' is a fragment of my ReadLine library
binding, originally a NativeCall interface.

The minimum case I can get is as below. Note *especially* the 'XXX'
section. If I comment out the 'make_pun', the error goes away.

--cut here--
my class void is repr('Uninstantiable') is export(​:types, :DEFAULT) {
};
my class Pointer is repr('CPointer') is export(​:types, :DEFAULT) { };

use MONKEY-TYPING;
augment class Pointer {
  my role TypedPointer[​::TValue = void] is Pointer is repr('CPointer')
{
  }

  # JMG XXX Comment out the body of this function and the bug goes
away.
  # XXX It may not *do* anything, but the error goes away.
  #
  method ^parameterize($, Mu​:U \t) {
  my \typed := TypedPointer[t];
  typed.^make_pun;
  }
}

multi trait_mod​:<is>(Routine $r, :$native!) is export(​:DEFAULT, :traits)
{
}

class Bug {
  sub rl_get_screen_size( Pointer[Int], Pointer[Int] )
  is native( 'foo' ) { * }
  method rl-get-screen-size( Pointer[Int] $r, Pointer[Int] $c ) {
  rl_get_screen_size( $r, $c ) }
}
--cut here--

@p6rt
Copy link
Author

p6rt commented Apr 27, 2015

From @masak

<masak> I should probably start by looking at the RT queue
<masak> notably #​124321
<jnthn> Calling .^make_pun is surely wrong
<jnthn> It'll create one every time
<jnthn> .^inheritalize gets the pun
<jnthn> Though maybe we should have a .^pun that does similar, and make inheritalize delegate to it.
<masak> ok, so that was easy. the problem is in... NativeCall, then?
<FROGGS> yes
* masak adds this to the ticket
* masak tries to reproduce the original problem, and also to make it go away with .^inheritalize
<masak> ...yep, and yep.
<masak> - typed.^make_pun;
<masak> + typed.^inheritalize;
<masak> fixes it.
<vendethiel> .oO( he's taking away our puns! )
<masak> vendethiel​: but note in the backlog that there's the possibility of adding a .^pun meta-method

@p6rt
Copy link
Author

p6rt commented Apr 27, 2015

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

@p6rt
Copy link
Author

p6rt commented Apr 27, 2015

From @masak

Fixed and tested as of 1c916bc.

Resolving ticket.

@p6rt p6rt closed this as completed Apr 27, 2015
@p6rt
Copy link
Author

p6rt commented Apr 27, 2015

@masak - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant