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

Variable lives outside of loop's scope #4331

Closed
p6rt opened this issue Jun 18, 2015 · 6 comments
Closed

Variable lives outside of loop's scope #4331

p6rt opened this issue Jun 18, 2015 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Jun 18, 2015

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

Searchable as RT125434$

@p6rt
Copy link
Author

p6rt commented Jun 18, 2015

From dvj@dagur.com

The following code​:

loop (my $i = 0;;) { }
loop (my $i = 0;;) { }

Gives the following error​:
Potential difficulties​:
  Redeclaration of symbol $i
  at my-i.p6​:2
  ------> loop (my $i⏏ = 0;;) { }

Also, rakudo goes into a state where it hangs with 99% CPU usage.

$ perl6 --version
This is perl6 version 2015.05-200-g2c58ee1 built on MoarVM version
2015.05-79-g458940f

@p6rt
Copy link
Author

p6rt commented Jun 18, 2015

From dvj@dagur.com

Correction​: rakudo does not hang, I didn't add a condition to the loop.
On Thu 18 Jun 2015 at 22​:37 perl6 via RT <perl6-bugs-followup@​perl.org>
wrote​:

Greetings,

This message has been automatically generated in response to the
creation of a trouble ticket regarding​:
"Variable lives outside of loop's scope",
a summary of which appears below.

There is no need to reply to this message right now. Your ticket has been
assigned an ID of [perl #​125434].

Please include the string​:

     \[perl #&#8203;125434\]

in the subject line of all future correspondence about this issue. To do
so,
you may reply to this message.

                    Thank you,
                    perl6\-bugs\-followup@&#8203;perl\.org

-------------------------------------------------------------------------
The following code​:

loop (my $i = 0;;) { }
loop (my $i = 0;;) { }

Gives the following error​:
Potential difficulties​:
Redeclaration of symbol $i
at my-i.p6​:2
------> loop (my $i⏏ = 0;;) { }

Also, rakudo goes into a state where it hangs with 99% CPU usage.

$ perl6 --version
This is perl6 version 2015.05-200-g2c58ee1 built on MoarVM version
2015.05-79-g458940f

@p6rt
Copy link
Author

p6rt commented Jun 19, 2015

From @hoelzro

Hi, thanks for reporting this! Scope works a little differently in Perl 6 than in Perl 5; variables declared via my in the init/condition/update portion of loop are not scoped to the block. See http://design.perl6.org/S04.html#The_Relationship_of_Blocks_and_Declarations for more information.

On 2015-06-18 14​:35​:54, dagur wrote​:

Correction​: rakudo does not hang, I didn't add a condition to the loop.
On Thu 18 Jun 2015 at 22​:37 perl6 via RT <perl6-bugs-followup@​perl.org>
wrote​:

Greetings,

This message has been automatically generated in response to the
creation of a trouble ticket regarding​:
"Variable lives outside of loop's scope",
a summary of which appears below.

There is no need to reply to this message right now. Your ticket has been
assigned an ID of [perl #​125434].

Please include the string​:

     \[perl #&#8203;125434\]

in the subject line of all future correspondence about this issue. To do
so,
you may reply to this message.

                    Thank you,
                    perl6\-bugs\-followup@&#8203;perl\.org

-------------------------------------------------------------------------
The following code​:

loop (my $i = 0;;) { }
loop (my $i = 0;;) { }

Gives the following error​:
Potential difficulties​:
Redeclaration of symbol $i
at my-i.p6​:2
------> loop (my $i⏏ = 0;;) { }

Also, rakudo goes into a state where it hangs with 99% CPU usage.

$ perl6 --version
This is perl6 version 2015.05-200-g2c58ee1 built on MoarVM version
2015.05-79-g458940f

@p6rt
Copy link
Author

p6rt commented Jun 19, 2015

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

@p6rt
Copy link
Author

p6rt commented Jun 19, 2015

From @jnthn

On Thu Jun 18 22​:48​:07 2015, rob@​hoelz.ro wrote​:

Hi, thanks for reporting this! Scope works a little differently in
Perl 6 than in Perl 5; variables declared via my in the
init/condition/update portion of loop are not scoped to the block.
See
http://design.perl6.org/S04.html#The_Relationship_of_Blocks_and_Declarations
for more information.

Indeed; not a bug.

@p6rt
Copy link
Author

p6rt commented Jun 19, 2015

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

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