Skip to content

Commit

Permalink
Fix manage technote and file futures (chapel-lang#24722)
Browse files Browse the repository at this point in the history
Fixes some incorrect code in the `manage.rst` technote and adds 3
futures for bugs captured in chapel-lang#24721

Tested new futures locally

[Reviewed by @dlongnecke-cray]
  • Loading branch information
jabraham17 authored Apr 1, 2024
2 parents e07916b + bc109c3 commit e6497a4
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/rst/technotes/manage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keyword to open the statement instead of ``with``:

.. code-block:: chapel
manage myManager() as myResource do
manage new myManager() as myResource do
myResource.doSomething();
The ``manage`` statement accepts a `manager` (the `myManager()` call
Expand All @@ -37,13 +37,13 @@ called ``enterContext()`` and ``exitContext()``:
record myManager : contextManager {
var x: int = 0;
proc enterContext() ref: int {
proc ref enterContext() ref: int {
writeln('x is: ', x);
return x;
}
proc exitContext(in err: owned Error?) {
if err then halt(err:string);
if err then halt(err!.message());
writeln('x is: ', x);
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/statements/manage/manageNonAggregate.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$CHPL_HOME/modules/internal/ChapelContext.chpl:37: internal error: UTI-MIS-1041 chpl version 2.1.0 pre-release (aafdad217f)
Note: This source location is a guess.

Internal errors indicate a bug in the Chapel compiler,
and we're sorry for the hassle. We would appreciate your reporting this bug --
please see https://chapel-lang.org/bugs.html for instructions. In the meantime,
the filename + line number above may be useful in working around the issue.

2 changes: 2 additions & 0 deletions test/statements/manage/manageNonAggregate.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var a = 1;
manage a {}
2 changes: 2 additions & 0 deletions test/statements/manage/manageNonAggregate.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bug: this should have a good error message, not an internal error
#24721
1 change: 1 addition & 0 deletions test/statements/manage/manageNonAggregate.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
manageNonAggregate.chpl:2: error: cannot use a non-context manager in a 'manage' statement
4 changes: 4 additions & 0 deletions test/statements/manage/missingNew.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
missingNew.chpl:14: warning: unnecessary type construction call
missingNew.chpl:1: note: 'myManager' has no generic fields
missingNew.chpl:14: note: remove the '()'
note: this warning will become an error in the future
16 changes: 16 additions & 0 deletions test/statements/manage/missingNew.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
record myManager: contextManager {
var x: int = 0;

proc ref enterContext() ref: int {
writeln('x is: ', x);
return x;
}

proc exitContext(in err: owned Error?) {
if err then halt(err!.message());
writeln('x is: ', x);
}
}
manage myManager() as x {
x = 1;
}
2 changes: 2 additions & 0 deletions test/statements/manage/missingNew.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bug: this should either be an error or default initialize 'x'
#24721
2 changes: 2 additions & 0 deletions test/statements/manage/missingNew.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x is: 0
x is: 1
1 change: 1 addition & 0 deletions test/statements/manage/missingNew.noexec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This test does not initialize data, any good file cause sporadic issues
8 changes: 8 additions & 0 deletions test/statements/manage/missingNewNoParen.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
missingNewNoParen.chpl:14: internal error: COD-CG--XPR-1674 chpl version 2.1.0 pre-release (aafdad217f)
Note: This source location is a guess.

Internal errors indicate a bug in the Chapel compiler,
and we're sorry for the hassle. We would appreciate your reporting this bug --
please see https://chapel-lang.org/bugs.html for instructions. In the meantime,
the filename + line number above may be useful in working around the issue.

16 changes: 16 additions & 0 deletions test/statements/manage/missingNewNoParen.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
record myManager: contextManager {
var x: int = 0;

proc ref enterContext() ref: int {
writeln('x is: ', x);
return x;
}

proc exitContext(in err: owned Error?) {
if err then halt(err!.message());
writeln('x is: ', x);
}
}
manage myManager as x {
x = 1;
}
2 changes: 2 additions & 0 deletions test/statements/manage/missingNewNoParen.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bug: this should have a good error message, not an internal error
#24721
1 change: 1 addition & 0 deletions test/statements/manage/missingNewNoParen.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
missingNewNoParen.chpl:14: error: cannot use a type in a 'manage' statement

0 comments on commit e6497a4

Please sign in to comment.