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

problem with optional positional parameters in sub MAIN #1443

Closed
p6rt opened this issue Dec 16, 2009 · 5 comments
Closed

problem with optional positional parameters in sub MAIN #1443

p6rt opened this issue Dec 16, 2009 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Dec 16, 2009

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

Searchable as RT71366$

@p6rt
Copy link
Author

p6rt commented Dec 16, 2009

From heikki@mehtanen.fi

Hey,

There seems to be problem with Rakudo handling optional positional
parameters in built-in sub MAIN.

Rakudo version​: fresh git build on 2009/12/26

Code snippet​: perl6 -e 'sub MAIN ($a, :$var) { say "a​: $a, optional​: $var"; }' param --var

results into​:
Too many positional parameters passed; got 2 but expected 1
in Main (file src/gen_setting.pm, line 324)


Heikki Mehtänen
heikki@​mehtanen.fi

@p6rt
Copy link
Author

p6rt commented Feb 23, 2011

From @moritz

On Wed Dec 16 07​:36​:01 2009, heikki@​mehtanen.fi wrote​:

Hey,

There seems to be problem with Rakudo handling optional positional
parameters in built-in sub MAIN.

Rakudo version​: fresh git build on 2009/12/26

Code snippet​: perl6 -e 'sub MAIN ($a, :$var) { say "a​: $a, optional​:
$var"; }' param --var

If you declare :$var without a type, it expects a value. If you want to
use as a valueless flag, you must declare it as Bool​:

$ ./perl6 -e 'sub MAIN ($a, :$var) { say "a​: $a, optional​: $var"; }'
param --var foo
a​: param, optional​: foo

$ ./perl6 -e 'sub MAIN ($a, Bool :$var) { say "a​: $a, optional​: $var";
}' param --var
a​: param, optional​: Bool​::True

However the fact remains that the error message (albeit different now
than what it was when you reported it) is less than awesome​:

./perl6 -e 'sub MAIN ($a, :$var) { say "a​: $a, optional​: $var"; }' param
--var
Undefined value shifted from empty list
  in 'MAIN' at line 1
  in 'MAIN' at line 1
  in <anon> at line 7576​:CORE.setting
  in 'MAIN_HELPER' at line 1
  in main program body at line 1

@p6rt
Copy link
Author

p6rt commented Feb 23, 2011

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

@p6rt
Copy link
Author

p6rt commented Mar 8, 2011

From @moritz

Now fixed in commit Toulouse-45-gbd134ec

@p6rt
Copy link
Author

p6rt commented Mar 8, 2011

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

@p6rt p6rt closed this as completed Mar 8, 2011
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