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

stringify and universal cast-to-string deprecation #22068

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2be5851
deprecating stringify and cast-anything-to-string
jeremiah-corrado Apr 5, 2023
3ea5072
fixing bugs in stringify deprecation
jeremiah-corrado Apr 5, 2023
63f53b9
more test corrections for stringify deprecation
jeremiah-corrado Apr 5, 2023
4e41ef5
fixing qio formatting of '%t', and test failures related to stringify…
jeremiah-corrado Apr 6, 2023
a426967
fix missing import
jeremiah-corrado Apr 6, 2023
afc88c4
add deprecation tests for stringify and cast to string
jeremiah-corrado Apr 6, 2023
976b7ba
more test corrections related to stringify deprecation and qio %t bug…
jeremiah-corrado Apr 7, 2023
3148f10
Merge branch 'main' into test-stringify-deprecation
jeremiah-corrado Apr 10, 2023
b8e147a
address more test failures due to stringify deprecation
jeremiah-corrado Apr 11, 2023
387e4f8
addressing enum:string related failures
jeremiah-corrado Apr 11, 2023
5a02bfb
removing unused code from stringcasts
jeremiah-corrado Apr 11, 2023
16bb887
more test corrections due to stringify deprecation
jeremiah-corrado Apr 11, 2023
507b1ea
removing cast-to-string deprecation warning when casting FCF types to…
jeremiah-corrado Apr 12, 2023
37bcc63
cleaning up stringify deprecation
jeremiah-corrado Apr 13, 2023
ffc4ea6
Merge branch 'main' into test-stringify-deprecation
jeremiah-corrado Jul 17, 2023
9dfc493
Merge branch 'pcnt-q-format-specifier' into test-stringify-deprecation
jeremiah-corrado Jul 19, 2023
c77b6a2
change some instances of %t to %?
jeremiah-corrado Jul 19, 2023
7f88bb6
fix merge conflict
jeremiah-corrado Jul 19, 2023
6449f65
more %t -> %? updates in tests
jeremiah-corrado Jul 19, 2023
4030c86
Merge branch 'pcnt-q-format-specifier' into test-stringify-deprecation
jeremiah-corrado Jul 20, 2023
d656d27
Merge branch 'main' into test-stringify-deprecation
jeremiah-corrado Jul 20, 2023
035433c
Merge branch 'main' into test-stringify-deprecation
jeremiah-corrado Jul 21, 2023
7035480
Merge branch 'main' into test-stringify-deprecation
jeremiah-corrado Jul 21, 2023
ef2099e
fixing failed tests from stringify deprecation merge with %t -> %? ch…
jeremiah-corrado Jul 21, 2023
5b1e3c2
Merge branch 'main' into test-stringify-deprecation
jeremiah-corrado Jul 24, 2023
4a44778
revert change to %t's behavior w.r.t. including .0 on whole number reals
jeremiah-corrado Jul 24, 2023
31fcde2
remove extra to_string code for default sparse
jeremiah-corrado Jul 25, 2023
7edc28b
replace old pragma no doc with chpldoc.nodoc
jeremiah-corrado Jul 25, 2023
52967c9
fix defualt rectangular comm debug formatting
jeremiah-corrado Jul 25, 2023
6c8a49a
adding try! to some string.format calls
jeremiah-corrado Jul 25, 2023
4c9f76b
removing extra newline
jeremiah-corrado Jul 25, 2023
cdf0c24
address reviewer feedback
jeremiah-corrado Jul 26, 2023
7c0b74a
Merge remote-tracking branch 'origin' into test-stringify-deprecation
jeremiah-corrado Jul 26, 2023
9702667
use correct string.format imports
jeremiah-corrado Jul 27, 2023
c38e7f6
strip unused regex code out of writef
jeremiah-corrado Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/internal/ChapelArray.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -2089,8 +2089,8 @@ module ChapelArray {
// How to cast arrays to strings
pragma "no doc"
operator :(x: [], type t:string) {
use IO;
return stringify(x);
import IO.FormattedIO.format;
return try! "%t".format(x);
}

pragma "no doc"
Expand Down
15 changes: 8 additions & 7 deletions modules/internal/ChapelDomain.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -1292,9 +1292,10 @@ module ChapelDomain {
*/
proc dim(d : int) {
use HaltWrappers;
import IO.FormattedIO.format;
if boundsChecking then
if (d < 0 || d >= rank) then
HaltWrappers.boundsCheckHalt("dim(" + d:string + ") is out-of-bounds; must be 0.." + (rank-1):string);
HaltWrappers.boundsCheckHalt(try! "dim(%t) is out-of-bounds; must be 0..%t".format(d, rank-1));
return _value.dsiDim(d);
}

Expand Down Expand Up @@ -1642,10 +1643,11 @@ module ChapelDomain {
It is an error if `idx` is not a valid index in `arr`.
*/
proc initialize(arr: [?d], idx, in value: arr.eltType) {
import IO.FormattedIO.format;

// Check to make sure value and array element types match.
if arr.eltType != value.type then
compilerError('Initialization value type \'' + value:string +
compilerError('Initialization value type \'' + value.type:string +
'\' does not match array element type \'' +
arr.eltType:string + '\'');

Expand All @@ -1669,15 +1671,14 @@ module ChapelDomain {
'the domain being resized');

if !arr.domain.contains(idx) then
halt('Array index out of bounds: ' + idx:string);
halt(try! 'Array index out of bounds: %t'.format(idx));

// Get a reference to the array slot.
ref elem = arr[idx];

if _checks {
if isElementInitialized(arr, idx) {
halt('Element at array index \'' + idx:string + '\' ' +
'is already initialized');
halt(try! "Element at array index '%t' is already initialized".format(idx));
}
}

Expand Down Expand Up @@ -2594,8 +2595,8 @@ module ChapelDomain {
if canResolveMethod(val._value, "doiToString") {
return val._value.doiToString();
} else {
use IO;
return stringify(val);
import IO.FormattedIO.format;
return try! "%t".format(val);
}
}

Expand Down
12 changes: 6 additions & 6 deletions modules/internal/DefaultRectangular.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -2176,12 +2176,12 @@ module DefaultRectangular {
//
private proc complexTransferComm(A, B, stridelevels:int(32), dstStride, srcStride, count, AFirst, BFirst) {
if debugDefaultDistBulkTransfer {
chpl_debug_writeln("BulkTransferStride with values:\n",
"\tLocale = ", stringify(here.id), "\n",
"\tStride levels = ", stringify(stridelevels), "\n",
"\tdstStride = ", stringify(dstStride), "\n",
"\tsrcStride = ", stringify(srcStride), "\n",
"\tcount = ", stringify(count));
chpl_debug_writeln(try! """BulkTransferStride with values:\n
\tLocale = %t\n
\tStride levels = %t\n
\tdstStride = %t\n
\tsrcStride = %t\n
\tcount = %t\n""".format(here.id, stridelevels, dstStride, srcStride, count));
}

const AO = A.getDataIndex(AFirst, getShifted = false);
Expand Down
29 changes: 29 additions & 0 deletions modules/internal/DefaultSparse.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,35 @@ module DefaultSparse {
}
}

// proc DefaultSparseDom.doiToString(): string {
// var s = "{";
// if rank == 1 {
// if (_nnz >= 1) {
// s += _indices(0):string;
// for i in 1.._nnz-1 {
// s += " " + _indices(i):string;
// }
// }
// s += "}";
// } else {
// s += "\n";
// if (_nnz >= 1) {
// var prevInd = _indices(0);
// s += " " + prevInd;
// for i in 1.._nnz-1 {
// if (prevInd(0) != _indices(i)(0)) {
// s += "\n";
// }
// prevInd = _indices(i);
// s += " " + prevInd:string;
// }
// s += "\n";
// }
// s += "}\n";
// }
// return s;
// }


proc DefaultSparseArr.dsiSerialWrite(f) throws {
if (rank == 1) {
Expand Down
18 changes: 18 additions & 0 deletions modules/internal/StringCasts.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ module StringCasts {
return false;
}

// homogenous tuples of primitive type
operator :(x: ?k*?t, type s:string) where isPrimitiveType(t) && isHomogeneousTupleType(x.type) {
var ret = "(";
for param i in 0..#k {
if i != 0 then ret += ", ";
if (x[i].type == c_string) {
try! {
ret += createStringWithNewBuffer(x[i]);
}
}
else {
ret += x[i]:string;
}
}
ret += ")";
jeremiah-corrado marked this conversation as resolved.
Show resolved Hide resolved
return ret;
}

//
// int
//
Expand Down
4 changes: 2 additions & 2 deletions modules/packages/SortedMap.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ module SortedMap {
var found: bool;
(found, result) = _set.lowerBound((k, nil));
if !found || comparator.compare(result[0], k) != 0 then
boundsCheckHalt("sortedMap index " + k:string + " out of bounds");
boundsCheckHalt(try! "sortedMap index %t out of bounds".format(k));
return result[1]!.val;
}
/*
Expand All @@ -356,7 +356,7 @@ module SortedMap {
var found: bool;
(found, result) = _set.lowerBound((k, nil));
if !found || comparator.compare(result[0], k) != 0 then
boundsCheckHalt("sortedMap index " + k:string + " out of bounds");
boundsCheckHalt(try! "sortedMap index %t out of bounds".format(k));

_set.remove((k, nil));

Expand Down
4 changes: 2 additions & 2 deletions modules/packages/SortedSet/Treap.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ module Treap {
proc _getReference(element: eltType) ref {
var node = _findRef(_root, element);
if node == nil then
boundsCheckHalt("index " + element:string + " out of bounds");
boundsCheckHalt(try! "index %t out of bounds".format(element));
ref result = node!.element;
return result;
}
Expand All @@ -384,7 +384,7 @@ module Treap {
proc const _getValue(element: eltType) const {
var node = _find(_root, element);
if node == nil then
boundsCheckHalt("index " + element:string + " out of bounds");
boundsCheckHalt(try! "index %t out of bounds".format(element));
var result = node!.element;
return result;
}
Expand Down
Loading