Hello, I've noticed the following error using repeat{} / break in R 3.4.1 running on Windows 10 and Windows Server 2008 (both 64-bit environments). When running a repeat function, the break command causes an error message if the repeat command refers to code within a file, but does not produce an error if the code is contained within the repeat{} command. For example, the following code runs fine: x <- 1 y <- 5 repeat { if(x < y) { print("No Break Dance :-(") x = x + 1 } else { print("Break Dance!") break } } [1] "No Break Dance :(" [1] "No Break Dance :(" [1] "No Break Dance :(" [1] "No Break Dance :(" [1] "No Break Dance :(" [1] "Break Dance!">However, if I take the loop contents of the repeat{} function, and save them to a file (breakTest.R) that contains the following: if(x < y) { print("No Break Dance :-(") x = x + 1 } else { print("Break Dance!") break } And then run the following code: x <- 1 y <- 5 repeat{ source("./breakTest.R") } I get the following error: [1] "No Break Dance :(" [1] "No Break Dance :(" [1] "No Break Dance :(" [1] "No Break Dance :(" [1] "No Break Dance :(" [1] "Break Dance!" Error in eval(ei, envir) : no loop for break/next, jumping to top level>This was not an issue with previous versions of R that I have used, including 3.3.3. Any suggestions? Is this a known bug with 3.4.1? Cheers- Peter ---------------------------------------------------------------- peter bosa metro modeling services 600 ne grand ave portland, or 97232 peter.bosa at oregonmetro.gov<mailto:peter.bosa at oregonmetro.gov> 503.797.1771 metro | making a great place www.oregonmetro.gov [[alternative HTML version deleted]]
Martin Maechler
2017-Aug-23 07:10 UTC
[Rd] Possible repeat{} / break function bug in R 3.4.1
>>>>> Peter Bosa <Peter.Bosa at oregonmetro.gov> >>>>> on Tue, 22 Aug 2017 14:39:50 +0000 writes:> Hello, I've noticed the following error using repeat{} / break in R 3.4.1 running on Windows 10 and Windows Server 2008 (both 64-bit environments). > When running a repeat function, the break command causes an error message if the repeat command refers to code within a file, but does not produce an error if the code is contained within the repeat{} command. > Hello, I've noticed the following error using repeat{} / break in R 3.4.1 running on Windows 10 and Windows Server 2008 (both 64-bit environments). > > When running a repeat function, the break command causes an error message if the repeat command refers to code within a file, but does not produce an error if the code is contained within the repeat{} command. > > For example, the following code runs fine: > > x <- 1 > y <- 5 > > repeat { > if(x < y) { > print("No Break Dance :-(") > x = x + 1 > } else { > print("Break Dance!") > break > } > } > > [1] "No Break Dance :(" > [1] "No Break Dance :(" > [1] "No Break Dance :(" > [1] "No Break Dance :(" > [1] "No Break Dance :(" > [1] "Break Dance!" > > > > However, if I take the loop contents of the repeat{} function, and save them to a file (breakTest.R) that contains the following: > > if(x < y) { > print("No Break Dance :-(") > x = x + 1 > } else { > print("Break Dance!") > break > } > > And then run the following code: > > x <- 1 > y <- 5 > > repeat{ > source("./breakTest.R") > } > > I get the following error: > > [1] "No Break Dance :(" > [1] "No Break Dance :(" > [1] "No Break Dance :(" > [1] "No Break Dance :(" > [1] "No Break Dance :(" > [1] "Break Dance!" > Error in eval(ei, envir) : no loop for break/next, jumping to top level > > > > This was not an issue with previous versions of R that I have used, including 3.3.3. > > Any suggestions? Is this a known bug with 3.4.1? Thank you, Peter! I can confirm what you are seeing (on Linux) in R version 3.4.0, 3.4.1, and "R devel", and also that this had worked w/o a problem in earlier versions of R, where I've looked at R version 3.3.3 and 3.2.5. I do think this is a bug, but it was not known till now. For ease of use, I attach the two R files to easily reproduce. Note I use writeLines() instead of print() as its output is "nicer". Best regards, Martin Maechler, ETH Zurich
Martin Maechler
2017-Aug-23 07:17 UTC
[Rd] Possible repeat{} / break function bug in R 3.4.1
>>>>> Martin Maechler <maechler at stat.math.ethz.ch> >>>>> on Wed, 23 Aug 2017 09:10:20 +0200 writes:>>>>> Peter Bosa <Peter.Bosa at oregonmetro.gov> >>>>> on Tue, 22 Aug 2017 14:39:50 +0000 writes:>> Hello, I've noticed the following error using repeat{} / break in R 3.4.1 running on Windows 10 and Windows Server 2008 (both 64-bit environments). >> When running a repeat function, the break command causes an error message if the repeat command refers to code within a file, but does not produce an error if the code is contained within the repeat{} command. >> Hello, I've noticed the following error using repeat{} / break in R 3.4.1 running on Windows 10 and Windows Server 2008 (both 64-bit environments). >> >> When running a repeat function, the break command causes an error message if the repeat command refers to code within a file, but does not produce an error if the code is contained within the repeat{} command. >> >> For example, the following code runs fine: >> >> x <- 1 >> y <- 5 >> >> repeat { >> if(x < y) { >> print("No Break Dance :-(") >> x = x + 1 >> } else { >> print("Break Dance!") >> break >> } >> } >> >> [1] "No Break Dance :(" >> [1] "No Break Dance :(" >> [1] "No Break Dance :(" >> [1] "No Break Dance :(" >> [1] "No Break Dance :(" >> [1] "Break Dance!" >> > >> >> However, if I take the loop contents of the repeat{} function, and save them to a file (breakTest.R) that contains the following: >> >> if(x < y) { >> print("No Break Dance :-(") >> x = x + 1 >> } else { >> print("Break Dance!") >> break >> } >> >> And then run the following code: >> >> x <- 1 >> y <- 5 >> >> repeat{ >> source("./breakTest.R") >> } >> >> I get the following error: >> >> [1] "No Break Dance :(" >> [1] "No Break Dance :(" >> [1] "No Break Dance :(" >> [1] "No Break Dance :(" >> [1] "No Break Dance :(" >> [1] "Break Dance!" >> Error in eval(ei, envir) : no loop for break/next, jumping to top level >> > >> >> This was not an issue with previous versions of R that I have used, including 3.3.3. >> >> Any suggestions? Is this a known bug with 3.4.1? > Thank you, Peter! > I can confirm what you are seeing (on Linux) in R version 3.4.0, > 3.4.1, and "R devel", and also that this had worked w/o a > problem in earlier versions of R, where I've looked at > R version 3.3.3 and 3.2.5. > I do think this is a bug, but it was not known till now. > For ease of use, I attach the two R files to easily reproduce. > Note I use writeLines() instead of print() as its output is "nicer". > Best regards, > Martin Maechler, ETH Zurich Trying again with the two attachment. Yes, I of all people (!!) should know that they must have an allowed MIME type; in this case text/plain ! Martin -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: breakTest.R URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20170823/9ee1b2d7/attachment.ksh> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: break-source_R341.R URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20170823/9ee1b2d7/attachment-0001.ksh>