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

Typed slurpy hashes aren't supported either #3314

Closed
p6rt opened this issue Jan 14, 2014 · 4 comments
Closed

Typed slurpy hashes aren't supported either #3314

p6rt opened this issue Jan 14, 2014 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jan 14, 2014

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

Searchable as RT120994$

@p6rt
Copy link
Author

p6rt commented Jan 14, 2014

From mark@kli.org

 

 
 
 
 
  Rakudo explicitly fails with a message when someone tries to use a
  typed slurpy positional argument, e.g. Int *@​_, but not for a typed
  slurpy named argument, like Int *%_.  But those aren't supported
  either​: the argument creates a parameter with type Associative[Int],
  but no matter what types are passed in, the dispatcher slurps up the
  extra named parameters into a plain Hash, which does not match.

 

  > sub foo(Int *@​_) { }

  ===SORRY!=== Error while compiling <unknown file>

  Slurpy positionals with type constraints are not supported.

  at <unknown file>​:1

  ------> sub foo(Int *@​_⏏) { }

      expecting any of​:

          formal parameter

          constraint

 

 

 

  > sub foo(Int *%_) { }

  sub foo(Int *%_) { ... }

  > foo(​:b(8))

  Nominal type check failed for parameter '%_'; expected
  Associative[Int] but got Hash instead

 

 

@p6rt
Copy link
Author

p6rt commented Oct 27, 2015

From @jnthn

On Mon Jan 13 18​:00​:36 2014, mark@​kli.org wrote​:

Rakudo explicitly fails with a message when someone tries to use a
typed
slurpy positional argument, e.g. Int *@​_, but not for a typed slurpy
named
argument, like Int *%_. But those aren't supported either​: the
argument creates
a parameter with type Associative[Int], but no matter what types are
passed in,
the dispatcher slurps up the extra named parameters into a plain Hash,
which
does not match.

sub foo(Int *@​_) { }
===SORRY!=== Error while compiling <unknown file>
Slurpy positionals with type constraints are not supported.
at <unknown file>​:1
------> sub foo(Int *@​_⏏) { }
expecting any of​:
formal parameter
constraint

sub foo(Int *%_) { }
sub foo(Int *%_) { ... }
foo(​:b(8))
Nominal type check failed for parameter '%_'; expected
Associative[Int] but got
Hash instead

It's now detected at compile time​:

$ perl6-m -e "sub foo(Int *%_) { }"
===SORRY!=== Error while compiling -e
Slurpy named parameters with type constraints are not supported
at -e​:1
------> sub foo(Int *%_<HERE>) { }

Test coverage added for this in S06-signature/slurpy-params.t.

@p6rt
Copy link
Author

p6rt commented Oct 27, 2015

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

@p6rt
Copy link
Author

p6rt commented Oct 27, 2015

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

@p6rt p6rt closed this as completed Oct 27, 2015
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