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

sub - optional parameters with a type cause exception when parameters omitted #3171

Closed
p6rt opened this issue Jun 20, 2013 · 5 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 20, 2013

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

Searchable as RT118555$

@p6rt
Copy link
Author

p6rt commented Jun 20, 2013

From samuel.sutch@gmail.com

# with Array[Str] ------------------------------
sub foo(Array[Str] :@​vars?) {
  say 'vars​: ', @​vars.perl;
}

foo(); # dies

# RETURNS​:
# ====> Nominal type check failed for parameter '@​vars'; expected
Positional but got Array instead

# with Str ---------------------------------------
sub foo2(Str :@​vars?) {
  say 'vars2​: ', @​vars.perl;
}

foo2(); # dies

# RETURNS​:
# ====> Nominal type check failed for parameter '@​vars'; expected
Positional but got Array instead

# without type --------------------------------
sub foo3(​:@​vars?) {
  say 'vars3​: ', @​vars.perl;
}

foo3(); # works

# RETURNS​:
# ====> 'vars3​: ', Array.new()

Example 1 and 2 should operate the same as 3.

@p6rt
Copy link
Author

p6rt commented Apr 27, 2017

From @MasterDuke17

Fixed in rakudo/rakudo#1072
Tests added in Raku/roast@785fea051b

@p6rt
Copy link
Author

p6rt commented Apr 27, 2017

@MasterDuke17 - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Apr 27, 2017
@p6rt p6rt added the Bug label Jan 5, 2020
@usev6
Copy link

usev6 commented Nov 13, 2020

For the record: This does not work on the JVM backend, yet. If I'm not mistaken a similar fix to rakudo/rakudo#1072 would be needed around https://github.com/rakudo/rakudo/blob/2f3de2faab/src/vm/jvm/runtime/org/raku/rakudo/Binder.java#L828 (and four lines below).

I don't know how to create a typed array or hash there, but at least this could serve as a pointer where to look for a fix.

@usev6
Copy link

usev6 commented Oct 28, 2022

Also relevant: rakudo/rakudo#4648

I opened a PR with similar code for the JVM backend: rakudo/rakudo#5088

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

No branches or pull requests

2 participants