Skip to content

Instantly share code, notes, and snippets.

@mppf
Created June 23, 2017 18:17
Show Gist options
  • Save mppf/76ab372f86c36cbb8a7c22647ff1fa62 to your computer and use it in GitHub Desktop.
Save mppf/76ab372f86c36cbb8a7c22647ff1fa62 to your computer and use it in GitHub Desktop.
record R {
var x: int;
proc deinit() {
writeln("Destroying ", x);
}
}
proc foo() {
var count = 0;
do {
writeln("creating 1");
var one = new R(1);
break;
writeln("creating 2");
var two = new R(2);
count += 1;
} while count < 2;
}
foo();
@ben-albrecht
Copy link

Correct behavior:

creating 1
Destroying 1

@mppf
Copy link
Author

mppf commented Jun 23, 2017

$ chpl break-in-do-while.chpl 
$ ./a.out
$

@ben-albrecht
Copy link

wat

@mppf
Copy link
Author

mppf commented Jun 23, 2017

Even simpler:

proc foo() {
  do {
    writeln("in loop");
    break;
  } while true;
}

foo();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment