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

increment/decrement of an uninitialized Bool variable throes error #2798

Closed
p6rt opened this issue Jun 24, 2012 · 3 comments
Closed

increment/decrement of an uninitialized Bool variable throes error #2798

p6rt opened this issue Jun 24, 2012 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Jun 24, 2012

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

Searchable as RT113816$

@p6rt
Copy link
Author

p6rt commented Jun 24, 2012

From @Siddhant

1. <sisar> r​: my Bool $x; say $x++;
<p6eval> rakudo 3a0e40​: OUTPUT«Type check failed in assignment to
'$x'; expected 'Bool' but got 'Int'␤ in sub postfix​:<++> at
src/gen/CORE.setting​:1342␤ in block <anon> at /tmp/yS4FLnf7uE​:1␤␤»

Expected output​: True

2. <sisar> r​: my Bool $x; say --$x;
<p6eval> rakudo 3a0e40​: OUTPUT«Type check failed in assignment to
'$x'; expected 'Bool' but got 'Int'␤ in sub prefix​:<--> at
src/gen/CORE.setting​:1338␤ in block <anon> at /tmp/ripRnRlVUe​:1␤␤»

Expected output​: False

S03​:539 covers postfix​:<++> on Bools. (just before postfix​:<++> on
Any/Numeric/Cool is described)

Also​:
<sisar> pmichaud​: note that the bug only occurs when $x is
uninitialized. The spec is silent(?) on incrementing uninitialized
Bool variables.
<pmichaud> sisar​: I'm expecting uninitialized Bool to work like
uninitialized Numeric
<pmichaud> principle of least surprise :)

@p6rt
Copy link
Author

p6rt commented Jun 24, 2012

From @pmichaud

Now fixed in f798fb1, with spectests added to S03-
operators/autoincrement.t .

Note that the expected output of the first example of the original ticket
is wrong; postincrement should return the value of $x before the
increment takes place (i.e., False). It returns False and not Bool in
order to remain analogous with what happens when postincrementing Int
(returns 0, not Int -- see S03.)

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Jun 24, 2012

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

@p6rt p6rt closed this as completed Jun 24, 2012
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