diff --git a/doc/rst/technotes/manage.rst b/doc/rst/technotes/manage.rst index ca6548b834da..be86e5f04a35 100644 --- a/doc/rst/technotes/manage.rst +++ b/doc/rst/technotes/manage.rst @@ -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 @@ -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); } } diff --git a/test/statements/manage/manageNonAggregate.bad b/test/statements/manage/manageNonAggregate.bad new file mode 100644 index 000000000000..bce2c736d003 --- /dev/null +++ b/test/statements/manage/manageNonAggregate.bad @@ -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. + diff --git a/test/statements/manage/manageNonAggregate.chpl b/test/statements/manage/manageNonAggregate.chpl new file mode 100644 index 000000000000..b2d2e26c27ca --- /dev/null +++ b/test/statements/manage/manageNonAggregate.chpl @@ -0,0 +1,2 @@ +var a = 1; +manage a {} diff --git a/test/statements/manage/manageNonAggregate.future b/test/statements/manage/manageNonAggregate.future new file mode 100644 index 000000000000..484d17107ed4 --- /dev/null +++ b/test/statements/manage/manageNonAggregate.future @@ -0,0 +1,2 @@ +bug: this should have a good error message, not an internal error +#24721 diff --git a/test/statements/manage/manageNonAggregate.good b/test/statements/manage/manageNonAggregate.good new file mode 100644 index 000000000000..38a591fae392 --- /dev/null +++ b/test/statements/manage/manageNonAggregate.good @@ -0,0 +1 @@ +manageNonAggregate.chpl:2: error: cannot use a non-context manager in a 'manage' statement diff --git a/test/statements/manage/missingNew.bad b/test/statements/manage/missingNew.bad new file mode 100644 index 000000000000..e14fac4d5284 --- /dev/null +++ b/test/statements/manage/missingNew.bad @@ -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 diff --git a/test/statements/manage/missingNew.chpl b/test/statements/manage/missingNew.chpl new file mode 100644 index 000000000000..552d7d7b9417 --- /dev/null +++ b/test/statements/manage/missingNew.chpl @@ -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; +} diff --git a/test/statements/manage/missingNew.future b/test/statements/manage/missingNew.future new file mode 100644 index 000000000000..5e2168b5be57 --- /dev/null +++ b/test/statements/manage/missingNew.future @@ -0,0 +1,2 @@ +bug: this should either be an error or default initialize 'x' +#24721 diff --git a/test/statements/manage/missingNew.good b/test/statements/manage/missingNew.good new file mode 100644 index 000000000000..2289eb0c10c4 --- /dev/null +++ b/test/statements/manage/missingNew.good @@ -0,0 +1,2 @@ +x is: 0 +x is: 1 diff --git a/test/statements/manage/missingNew.noexec b/test/statements/manage/missingNew.noexec new file mode 100644 index 000000000000..07c4772ab2e3 --- /dev/null +++ b/test/statements/manage/missingNew.noexec @@ -0,0 +1 @@ +This test does not initialize data, any good file cause sporadic issues diff --git a/test/statements/manage/missingNewNoParen.bad b/test/statements/manage/missingNewNoParen.bad new file mode 100644 index 000000000000..91dcecb784dd --- /dev/null +++ b/test/statements/manage/missingNewNoParen.bad @@ -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. + diff --git a/test/statements/manage/missingNewNoParen.chpl b/test/statements/manage/missingNewNoParen.chpl new file mode 100644 index 000000000000..512b6acdc9f6 --- /dev/null +++ b/test/statements/manage/missingNewNoParen.chpl @@ -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; +} diff --git a/test/statements/manage/missingNewNoParen.future b/test/statements/manage/missingNewNoParen.future new file mode 100644 index 000000000000..484d17107ed4 --- /dev/null +++ b/test/statements/manage/missingNewNoParen.future @@ -0,0 +1,2 @@ +bug: this should have a good error message, not an internal error +#24721 diff --git a/test/statements/manage/missingNewNoParen.good b/test/statements/manage/missingNewNoParen.good new file mode 100644 index 000000000000..89d6342d36b7 --- /dev/null +++ b/test/statements/manage/missingNewNoParen.good @@ -0,0 +1 @@ +missingNewNoParen.chpl:14: error: cannot use a type in a 'manage' statement