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

A where clause should not apply to a missing optional argument. #1940

Closed
p6rt opened this issue Jul 14, 2010 · 4 comments
Closed

A where clause should not apply to a missing optional argument. #1940

p6rt opened this issue Jul 14, 2010 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 14, 2010

Migrated from rt.perl.org#76514 (status was 'rejected')

Searchable as RT76514$

@p6rt
Copy link
Author

p6rt commented Jul 14, 2010

From @cognominal

Here, the where clause is applied to the default value, the undefined type Any
and results in an error.

$ perl6

sub a(Range $r? where {$r.min >= 0} ) {}; a()
Type objects are abstract and have no attributes, but you tried to access $!min

--
cognominal stef

@p6rt
Copy link
Author

p6rt commented Jul 15, 2010

From @jnthn

On Wed Jul 14 16​:25​:26 2010, cognominal wrote​:

Here, the where clause is applied to the default value, the undefined
type Any
and results in an error.

$ perl6

sub a(Range $r? where {$r.min >= 0} ) {}; a()
Type objects are abstract and have no attributes, but you tried to
access $!min

Rejecting this one - it's behaving as expected. From #perl6​:

12​:31 <@​jnthn> Opinions on
http://rt.perl.org/rt3/Ticket/Display.html?id=76514 ?
12​:31 <@​jnthn> Tempted to reject as "not a bug".
12​:31 <@​jnthn> Default values should be subject to checking too.
12​:32 <@​moritz_> +1
12​:32 <@​jnthn> (and sticking in the Range type object is just a kinda
default value)
12​:32 <@​moritz_> the correct solution is to supply a custom default
value, of course
12​:36 <@​jnthn> OK, thanks. :-)

Essentially, if you're going to put constraints on a parameter or
variable, then those constraints should always apply. You could​:

* Supply a default value

* Tweak the constraint to allow !$r.defined || $r.min >= 0

To resolve this.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Jul 15, 2010

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

@p6rt
Copy link
Author

p6rt commented Jul 15, 2010

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

@p6rt p6rt closed this as completed Jul 15, 2010
@p6rt p6rt added the Bug label Jan 5, 2020
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

1 participant