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

Strange type error when using lexical regexes in a method #3192

Closed
p6rt opened this issue Jul 23, 2013 · 4 comments
Closed

Strange type error when using lexical regexes in a method #3192

p6rt opened this issue Jul 23, 2013 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jul 23, 2013

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

Searchable as RT118985$

@p6rt
Copy link
Author

p6rt commented Jul 23, 2013

From @hoelzro

Using a lexical regex in a method fails with a strange error​:

Nominal type check failed for parameter ''; expected HasMethod but got
Cursor instead
  in regex anything at test.p6​:34
  in method INTERPOLATE at src/gen/CORE.setting​:10730
  in regex at test.p6​:36
  in method ACCEPTS at src/gen/CORE.setting​:10894
  in method ACCEPTS at src/gen/CORE.setting​:703
  in method parse at test.p6​:36
  in block at test.p6​:45

The attached file includes examples.

@p6rt
Copy link
Author

p6rt commented Jul 23, 2013

From @hoelzro

use v6;

sub parse(Str $input) {
  my regex anything { . }

  if $input ~~ /<anything>/ {
  }
}

class HasSub {
  sub parse(Str $input) {
  my regex anything { . }

  if $input ~~ /<anything>/ {
  }
  }

  method call-parse-sub(Str $input) {
  parse($input);
  }
}

class HasSubMethod {
  submethod parse(Str $input) {
  my regex anything { . }

  if $input ~~ /<anything>/ {
  }
  }
}

class HasMethod {
  method parse(Str $input) {
  my regex anything { . }

  if $input ~~ /<anything>/ {
  }
  }
}

my @​forms = (
  { parse('foo'); }, # no problems
  { HasSub.call-parse-sub('foo') }, # fails
  { HasSubMethod.parse('foo') }, # fails
  { HasMethod.parse('foo') }, # fails
);

for @​forms -> $form {
  try {
  $form();
  CATCH { default { .say } }
  }
}

@p6rt
Copy link
Author

p6rt commented Jul 20, 2014

From @FROGGS

Fixed at​: rakudo/rakudo@57a08ad
Tests​: Raku/roast@ff5bd050c0

@p6rt p6rt closed this as completed Jul 20, 2014
@p6rt
Copy link
Author

p6rt commented Jul 20, 2014

@FROGGS - Status changed from 'new' 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