From b7a2e95b6552211fdbe4fcb65fbcf5e28af01b89 Mon Sep 17 00:00:00 2001 From: Vassily Litvinov Date: Wed, 6 Mar 2024 22:55:38 -0800 Subject: [PATCH 1/7] More robust domain '=' and add() Signed-off-by: Vassily Litvinov --- modules/internal/ChapelDomain.chpl | 21 +++++++++++-- modules/internal/DefaultAssociative.chpl | 39 +++++++++++++----------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/modules/internal/ChapelDomain.chpl b/modules/internal/ChapelDomain.chpl index 8f4d7ee049d0..47bafa6f3120 100644 --- a/modules/internal/ChapelDomain.chpl +++ b/modules/internal/ChapelDomain.chpl @@ -763,10 +763,27 @@ module ChapelDomain { operator =(ref a: domain, b: _tuple) { if chpl__isLegalRectTupDomAssign(a, b) { a = {(...b)}; + } else if a.isRectangular() { + compilerError("cannot assign a ", b.type:string, + " to a rectangular domain"); } else { a.clear(); - for ind in 0..#b.size { - a.add(b(ind)); + if isHomogeneousTuple(b) { + // let the backend compiler unroll this loop if desired + for ind in 0..#b.size { + if ! isCoercible(b(ind).type, a.idxType) then + compilerError("cannot assign a tuple of ", b(ind).type:string, + " into an associative domain with idxType ", a.idxType:string); + a.add(b(ind)); + } + } else { + // unroll in the source code to allow heterogenous tuple elements + for ind in b { + if ! isCoercible(ind.type, a.idxType) then + compilerError("cannot assign a tuple containing ", ind.type:string, + " into an associative domain with idxType ", a.idxType:string); + a.add(ind); + } } } } diff --git a/modules/internal/DefaultAssociative.chpl b/modules/internal/DefaultAssociative.chpl index e55569f20554..dadc447e599c 100644 --- a/modules/internal/DefaultAssociative.chpl +++ b/modules/internal/DefaultAssociative.chpl @@ -317,26 +317,28 @@ module DefaultAssociative { } // returns the number of indices added + // todo: when is it better to have a ref or const ref intent for 'idx'? override proc dsiAdd(in idx) { - // add helpers will return a tuple like (slotNum, numIndicesAdded); - - // these two seemingly redundant lines were necessary to work around a - // compiler bug. I was unable to create a smaller case that has the same - // issue. - // More: `return _addWrapper(idx)[2]` Call to _addWrapper seems to - // have no effect when `idx` is a range and the line is promoted. My - // understanding of promotion makes me believe that things might go haywire - // since return type of the method becomes an array(?). However, it seemed - // that _addWrapper is never called when the return statement is promoted. - // I checked the C code and couldn't see any call to _addWrapper. - // I tried to replicate the issue with generic classes but it always - // worked smoothly. - const numInds = _addWrapper(idx)[1]; - return numInds; + if isCoercible(idx.type, idxType) then + return _addWrapper(idx); + + type promoType = __primitive("scalar promotion type", idx); + if isCoercible(promoType, idxType) { + if parSafe { + return + reduce _addWrapper(idx); + } else { + // not parSafe, so execute serially + var addCount = 0; + for oneIdx in idx do + addCount += _addWrapper(oneIdx); + return addCount; + } + } + compilerError("cannot add a ", idx.type:string, + " to an associative domain with idxType ", idxType:string); } proc _addWrapper(in idx: idxType) { - var slotNum = -1; var retVal = 0; on this { @@ -345,10 +347,11 @@ module DefaultAssociative { unlockTable(); } - (slotNum, retVal) = _add(idx); + const (slotNum, addCount) = _add(idx); + retVal = addCount; } - return (slotNum, retVal); + return retVal; } proc _add(in idx: idxType) { From 514a1724559e142340be0332f82549876a4a3b80 Mon Sep 17 00:00:00 2001 From: Vassily Litvinov Date: Thu, 7 Mar 2024 14:03:10 -0800 Subject: [PATCH 2/7] Fixes and improvements Signed-off-by: Vassily Litvinov --- modules/internal/ChapelDomain.chpl | 106 +++++++++++++++-------- modules/internal/DefaultAssociative.chpl | 22 +---- 2 files changed, 69 insertions(+), 59 deletions(-) diff --git a/modules/internal/ChapelDomain.chpl b/modules/internal/ChapelDomain.chpl index 47bafa6f3120..ecbccee11413 100644 --- a/modules/internal/ChapelDomain.chpl +++ b/modules/internal/ChapelDomain.chpl @@ -541,6 +541,17 @@ module ChapelDomain { (d1.isAssociative() && d2.isAssociative()) || (d1.isSparse() && d2.isSparse() ); + // This is perhaps an approximation, for use in error messages. + private proc canBeIteratedOver(const ref arg) param { + use Reflection; + return canResolveMethod(arg, "these"); + } + + private proc domainDescription(const ref d) param do return + if d.isRectangular() then "a rectangular " + d.rank:string + "-dim domain" + else if d.isSparse() then "a sparse " + d.rank:string + "-dim domain" + else "an associative domain"; + @chpldoc.nodoc @unstable("'-' on domains is unstable and may change in the future") operator -(a :domain, b :domain) where (a.type == b.type) && @@ -735,28 +746,22 @@ module ChapelDomain { // // Return true if t is a tuple of ranges that is legal to assign to // rectangular domain d + // The check that d.idxType accepts t(i) is done in op=(domain,domain). // proc chpl__isLegalRectTupDomAssign(d, t) param { - proc isRangeTuple(a) param { - proc peelArgs(first, rest...) param { - return if rest.size > 1 then - isRange(first) && peelArgs((...rest)) - else - isRange(first) && isRange(rest(0)); - } - proc peelArgs(first) param do return isRange(first); + if ! d.isRectangular() then return false; + if ! (d.rank == t.size) then return false; - return if !isTuple(a) then false else peelArgs((...a)); - } + // does the tuple 't' contain only ranges? + for param dim in 0..t.size-1 do + if ! isRange(t(dim)) then return false; - proc strideSafe(d, rt, param dim: int=0) param { - return if dim == d.rank-1 then - chpl_assignStrideIsSafe(d.dim(dim), rt(dim)) - else - chpl_assignStrideIsSafe(d.dim(dim), rt(dim)) && - strideSafe(d, rt, dim+1); - } - return isRangeTuple(t) && d.rank == t.size && strideSafe(d, t); + // are those ranges' 'strides' compatible with 'd'? + for param dim in 0..t.size-1 do + if ! chpl_assignStrideIsSafe(d.dim(dim), t(dim)) then return false; + + // all checks passed + return true; } @chpldoc.nodoc @@ -768,23 +773,14 @@ module ChapelDomain { " to a rectangular domain"); } else { a.clear(); - if isHomogeneousTuple(b) { - // let the backend compiler unroll this loop if desired - for ind in 0..#b.size { - if ! isCoercible(b(ind).type, a.idxType) then - compilerError("cannot assign a tuple of ", b(ind).type:string, - " into an associative domain with idxType ", a.idxType:string); + if isHomogeneousTuple(b) then + // let the backend compiler unroll this loop to optimize + for ind in 0..#b.size do a.add(b(ind)); - } - } else { + else // unroll in the source code to allow heterogenous tuple elements - for ind in b { - if ! isCoercible(ind.type, a.idxType) then - compilerError("cannot assign a tuple containing ", ind.type:string, - " into an associative domain with idxType ", a.idxType:string); + for ind in b do a.add(ind); - } - } } } @@ -796,7 +792,9 @@ module ChapelDomain { @chpldoc.nodoc operator =(ref a: domain, b) { // b is iteratable if a.isRectangular() then - compilerError("Illegal assignment to a rectangular domain"); + compilerError("assigning ", b.type:string, " to a rectangular domain"); + if ! canBeIteratedOver(b) then + compilerError("assigning ", b.type:string, " to an irregular domain"); a.clear(); for ind in b { a.add(ind); @@ -943,7 +941,7 @@ module ChapelDomain { pragma "no copy" var lhs = chpl__coerceHelp(dstType, definedConst); if lhs.isRectangular() then - compilerError("Illegal assignment to a rectangular domain"); + compilerError("assigning ", rhs.type:string, " to a rectangular domain"); lhs.clear(); for ind in rhs { lhs.add(ind); @@ -957,7 +955,7 @@ module ChapelDomain { pragma "no copy" var lhs = chpl__coerceHelp(dstType, definedConst); if lhs.isRectangular() then - compilerError("Illegal assignment to a rectangular domain"); + compilerError("assigning ", rhs.type:string, " to a rectangular domain"); lhs.clear(); for ind in rhs { lhs.add(ind); @@ -972,7 +970,9 @@ module ChapelDomain { pragma "no copy" var lhs = chpl__coerceHelp(dstType, definedConst); if lhs.isRectangular() then - compilerError("Illegal assignment to a rectangular domain"); + compilerError("assigning ", rhs.type:string, " to a rectangular domain"); + if ! canBeIteratedOver(rhs) then + compilerError("assigning ", rhs.type:string, " to an irregular domain"); lhs.clear(); for ind in rhs { lhs.add(ind); @@ -986,7 +986,9 @@ module ChapelDomain { pragma "no copy" var lhs = chpl__coerceHelp(dstType, definedConst); if lhs.isRectangular() then - compilerError("Illegal assignment to a rectangular domain"); + compilerError("assigning ", rhs.type:string, " to a rectangular domain"); + if ! canBeIteratedOver(rhs) then + compilerError("assigning ", rhs.type:string, " to an irregular domain"); lhs.clear(); for ind in rhs { lhs.add(ind); @@ -2130,13 +2132,41 @@ module ChapelDomain { return _value.dsiRemove(idx); } + // todo: when is it better to have a ref or const ref intent for 'idx'? /* Adds index ``idx`` to this domain. This method is also available as the ``+=`` operator. + Returns the number of indices that were added. The domain must be irregular. */ proc ref add(in idx) { - return _value.dsiAdd(idx); + // ensure that the rest of add() deals only with irregular domains + if isRectangular() then + compilerError("Cannot add indices to a rectangular domain"); + + // 'idx' is an index + if isCoercible(idx.type, fullIdxType) then + return _value.dsiAdd(idx); + + // allow promotion + type promoType = __primitive("scalar promotion type", idx); + if isCoercible(promoType, fullIdxType) { + // sparse domains are currently not parSafe + if isAssociative() && this.parSafe { + return + reduce dsiAdd(idx); + } + else { + // not parSafe, so execute serially + var addCount = 0; + for oneIdx in idx do + addCount += dsiAdd(oneIdx); + return addCount; + } + } + + // for now, disallow calling add() in any other way + compilerError("cannot add a ", idx.type:string, " to ", + domainDescription(this), " with idxType ", idxType:string); } @chpldoc.nodoc diff --git a/modules/internal/DefaultAssociative.chpl b/modules/internal/DefaultAssociative.chpl index dadc447e599c..54929253e755 100644 --- a/modules/internal/DefaultAssociative.chpl +++ b/modules/internal/DefaultAssociative.chpl @@ -318,27 +318,7 @@ module DefaultAssociative { // returns the number of indices added // todo: when is it better to have a ref or const ref intent for 'idx'? - override proc dsiAdd(in idx) { - if isCoercible(idx.type, idxType) then - return _addWrapper(idx); - - type promoType = __primitive("scalar promotion type", idx); - if isCoercible(promoType, idxType) { - if parSafe { - return + reduce _addWrapper(idx); - } else { - // not parSafe, so execute serially - var addCount = 0; - for oneIdx in idx do - addCount += _addWrapper(oneIdx); - return addCount; - } - } - compilerError("cannot add a ", idx.type:string, - " to an associative domain with idxType ", idxType:string); - } - - proc _addWrapper(in idx: idxType) { + override proc dsiAdd(in idx: idxType) { var retVal = 0; on this { From 662b95baa42af8987d010fe55386f175825e24a9 Mon Sep 17 00:00:00 2001 From: Vassily Litvinov Date: Thu, 7 Mar 2024 15:53:22 -0800 Subject: [PATCH 3/7] More fixes Signed-off-by: Vassily Litvinov --- modules/internal/ChapelDomain.chpl | 11 +++++++---- modules/internal/DefaultAssociative.chpl | 9 ++++++++- test/arrays/bradc/assignArithArrToDom.good | 2 +- .../initDomainWithNonDomain-nongeneric.good | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/modules/internal/ChapelDomain.chpl b/modules/internal/ChapelDomain.chpl index ecbccee11413..9a3ae136d32f 100644 --- a/modules/internal/ChapelDomain.chpl +++ b/modules/internal/ChapelDomain.chpl @@ -544,7 +544,8 @@ module ChapelDomain { // This is perhaps an approximation, for use in error messages. private proc canBeIteratedOver(const ref arg) param { use Reflection; - return canResolveMethod(arg, "these"); + return isSubtype(arg.type, _iteratorRecord) || + canResolveMethod(arg, "these"); } private proc domainDescription(const ref d) param do return @@ -2145,7 +2146,9 @@ module ChapelDomain { compilerError("Cannot add indices to a rectangular domain"); // 'idx' is an index - if isCoercible(idx.type, fullIdxType) then + if isCoercible(idx.type, fullIdxType) || + // sparse 1-d domains also allow adding 1-tuples + isSparse() && rank == 1 && isCoercible(idx.type, 1*idxType) then return _value.dsiAdd(idx); // allow promotion @@ -2153,13 +2156,13 @@ module ChapelDomain { if isCoercible(promoType, fullIdxType) { // sparse domains are currently not parSafe if isAssociative() && this.parSafe { - return + reduce dsiAdd(idx); + return + reduce [oneIdx in idx] _value.dsiAdd(oneIdx); } else { // not parSafe, so execute serially var addCount = 0; for oneIdx in idx do - addCount += dsiAdd(oneIdx); + addCount += _value.dsiAdd(oneIdx); return addCount; } } diff --git a/modules/internal/DefaultAssociative.chpl b/modules/internal/DefaultAssociative.chpl index 54929253e755..2a28624b5540 100644 --- a/modules/internal/DefaultAssociative.chpl +++ b/modules/internal/DefaultAssociative.chpl @@ -318,7 +318,14 @@ module DefaultAssociative { // returns the number of indices added // todo: when is it better to have a ref or const ref intent for 'idx'? - override proc dsiAdd(in idx: idxType) { + // Ideally, we would like to restrict `idx: idxType`. If we do, however, + // then the compiler will choose BaseAssociativeDom.dsiAdd(), undesirably, + // when the actual is not of idxType, however is coercible to it. Ex: + // test/domains/sungeun/assoc/parSafeMember.chpl + override proc dsiAdd(in idx) { + // domain.add(idx) ensures the following: + compilerAssert(isCoercible(idx.type, idxType)); + var retVal = 0; on this { diff --git a/test/arrays/bradc/assignArithArrToDom.good b/test/arrays/bradc/assignArithArrToDom.good index ed980117016a..afe831714768 100644 --- a/test/arrays/bradc/assignArithArrToDom.good +++ b/test/arrays/bradc/assignArithArrToDom.good @@ -1 +1 @@ -assignArithArrToDom.chpl:5: error: Illegal assignment to a rectangular domain +assignArithArrToDom.chpl:5: error: assigning [domain(2,int(64),one)] real(64) to a rectangular domain diff --git a/test/domains/compilerErrors/initDomainWithNonDomain-nongeneric.good b/test/domains/compilerErrors/initDomainWithNonDomain-nongeneric.good index 31a1f184da4e..ee2bf139d253 100644 --- a/test/domains/compilerErrors/initDomainWithNonDomain-nongeneric.good +++ b/test/domains/compilerErrors/initDomainWithNonDomain-nongeneric.good @@ -1 +1 @@ -initDomainWithNonDomain-nongeneric.chpl:4: error: Illegal assignment to a rectangular domain +initDomainWithNonDomain-nongeneric.chpl:4: error: assigning real(64) to a rectangular domain From 75b22829615dde1a4bd510e187a61578c6a6d518 Mon Sep 17 00:00:00 2001 From: Vassily Litvinov Date: Thu, 7 Mar 2024 16:03:21 -0800 Subject: [PATCH 4/7] Add newlines; minor revert from 24352 Signed-off-by: Vassily Litvinov --- .../deitz/part4/test_array_of_associative_arrays.compopts | 2 +- test/arrays/localQueries/localAccess.chpl | 3 ++- test/associative/bradc/removeResizeViaAssign.compopts | 2 +- test/studies/twitter/strshuffle.compopts | 2 +- test/unstable/assoc-domain-parsafe-changed.compopts | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/arrays/deitz/part4/test_array_of_associative_arrays.compopts b/test/arrays/deitz/part4/test_array_of_associative_arrays.compopts index d5a312042d82..ab90c63f3ded 100644 --- a/test/arrays/deitz/part4/test_array_of_associative_arrays.compopts +++ b/test/arrays/deitz/part4/test_array_of_associative_arrays.compopts @@ -1 +1 @@ --snoParSafeWarning \ No newline at end of file +-snoParSafeWarning diff --git a/test/arrays/localQueries/localAccess.chpl b/test/arrays/localQueries/localAccess.chpl index b51782e4b130..704773490a04 100644 --- a/test/arrays/localQueries/localAccess.chpl +++ b/test/arrays/localQueries/localAccess.chpl @@ -25,7 +25,8 @@ var baseDom = {1..10}; } { - var assocDom: domain(string) = {"foo", "bar"}; + var assocDom: domain(string); + assocDom += ["foo", "bar"]; test(assocDom); } diff --git a/test/associative/bradc/removeResizeViaAssign.compopts b/test/associative/bradc/removeResizeViaAssign.compopts index 7434bfa49a6f..c8b2a56bdc12 100644 --- a/test/associative/bradc/removeResizeViaAssign.compopts +++ b/test/associative/bradc/removeResizeViaAssign.compopts @@ -1 +1 @@ --snoParSafeWarning -M../common \ No newline at end of file +-snoParSafeWarning -M../common diff --git a/test/studies/twitter/strshuffle.compopts b/test/studies/twitter/strshuffle.compopts index d5a312042d82..ab90c63f3ded 100644 --- a/test/studies/twitter/strshuffle.compopts +++ b/test/studies/twitter/strshuffle.compopts @@ -1 +1 @@ --snoParSafeWarning \ No newline at end of file +-snoParSafeWarning diff --git a/test/unstable/assoc-domain-parsafe-changed.compopts b/test/unstable/assoc-domain-parsafe-changed.compopts index c1286962e67a..d45dc51968dd 100644 --- a/test/unstable/assoc-domain-parsafe-changed.compopts +++ b/test/unstable/assoc-domain-parsafe-changed.compopts @@ -1,4 +1,4 @@ # assoc-domain-parsafe-changed.default.good -snoParSafeWarning # assoc-domain-parsafe-changed.noParSafe.good -sassocParSafeDefault # assoc-domain-parsafe-changed.parSafeDefault.good --snoParSafeWarning -sassocParSafeDefault # assoc-domain-parsafe-changed.parSafeDefault.good # effectively the same as passing just -sassocParSafeDefault \ No newline at end of file +-snoParSafeWarning -sassocParSafeDefault # assoc-domain-parsafe-changed.parSafeDefault.good # effectively the same as passing just -sassocParSafeDefault From 9e9e65da728a8381865914653804296b3fad05e7 Mon Sep 17 00:00:00 2001 From: Vassily Litvinov Date: Thu, 7 Mar 2024 16:31:42 -0800 Subject: [PATCH 5/7] Reinstate another check Signed-off-by: Vassily Litvinov --- modules/internal/ChapelDomain.chpl | 19 +++++++++++++++++-- .../assoc-from-tuple-of-ranges.chpl | 4 ++++ .../assoc-from-tuple-of-ranges.compopts | 1 + .../assoc-from-tuple-of-ranges.good | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 test/domains/compilerErrors/assoc-from-tuple-of-ranges.chpl create mode 100644 test/domains/compilerErrors/assoc-from-tuple-of-ranges.compopts create mode 100644 test/domains/compilerErrors/assoc-from-tuple-of-ranges.good diff --git a/modules/internal/ChapelDomain.chpl b/modules/internal/ChapelDomain.chpl index 9a3ae136d32f..2b15a598f3ec 100644 --- a/modules/internal/ChapelDomain.chpl +++ b/modules/internal/ChapelDomain.chpl @@ -744,6 +744,17 @@ module ChapelDomain { } } + proc chpl__checkTupIrregDomAssign(const ref d, const ref idx, param msg) { + if isCoercible(idx.type, d.fullIdxType) || + // sparse 1-d domains also allow adding 1-tuples + d.isSparse() && d.rank == 1 && isCoercible(idx.type, 1*d.idxType) + then return; + + compilerError("cannot assign a tuple ", msg, idx.type:string, + " into ", domainDescription(d), + " with idxType ", d.idxType:string); + } + // // Return true if t is a tuple of ranges that is legal to assign to // rectangular domain d @@ -776,12 +787,16 @@ module ChapelDomain { a.clear(); if isHomogeneousTuple(b) then // let the backend compiler unroll this loop to optimize - for ind in 0..#b.size do + for ind in 0..#b.size { + chpl__checkTupIrregDomAssign(a, b(ind), "of "); a.add(b(ind)); + } else // unroll in the source code to allow heterogenous tuple elements - for ind in b do + for ind in b { + chpl__checkTupIrregDomAssign(a, ind, "containing "); a.add(ind); + } } } diff --git a/test/domains/compilerErrors/assoc-from-tuple-of-ranges.chpl b/test/domains/compilerErrors/assoc-from-tuple-of-ranges.chpl new file mode 100644 index 000000000000..a486b47a2031 --- /dev/null +++ b/test/domains/compilerErrors/assoc-from-tuple-of-ranges.chpl @@ -0,0 +1,4 @@ +// This was legal since 791f0d3488a until #24507 + +var D2: domain(int); +D2 = (1..3, 3..6); diff --git a/test/domains/compilerErrors/assoc-from-tuple-of-ranges.compopts b/test/domains/compilerErrors/assoc-from-tuple-of-ranges.compopts new file mode 100644 index 000000000000..ab90c63f3ded --- /dev/null +++ b/test/domains/compilerErrors/assoc-from-tuple-of-ranges.compopts @@ -0,0 +1 @@ +-snoParSafeWarning diff --git a/test/domains/compilerErrors/assoc-from-tuple-of-ranges.good b/test/domains/compilerErrors/assoc-from-tuple-of-ranges.good new file mode 100644 index 000000000000..f84bd74e64c8 --- /dev/null +++ b/test/domains/compilerErrors/assoc-from-tuple-of-ranges.good @@ -0,0 +1 @@ +assoc-from-tuple-of-ranges.chpl:4: error: cannot assign a tuple of range(int(64),both,one) into an associative domain with idxType int(64) From e4dca0186d3d2371925670ab73382af5e1e8b499 Mon Sep 17 00:00:00 2001 From: Vassily Litvinov Date: Thu, 7 Mar 2024 18:00:03 -0800 Subject: [PATCH 6/7] add tests Signed-off-by: Vassily Litvinov --- test/domains/compilerErrors/rect-mismatch-type-1.chpl | 4 ++++ test/domains/compilerErrors/rect-mismatch-type-1.good | 1 + test/domains/compilerErrors/sparseSubdom-mismatch-1.chpl | 3 +++ test/domains/compilerErrors/sparseSubdom-mismatch-1.good | 1 + test/domains/compilerErrors/sparseSubdom-mismatch-2.chpl | 3 +++ test/domains/compilerErrors/sparseSubdom-mismatch-2.good | 1 + 6 files changed, 13 insertions(+) create mode 100644 test/domains/compilerErrors/rect-mismatch-type-1.chpl create mode 100644 test/domains/compilerErrors/rect-mismatch-type-1.good create mode 100644 test/domains/compilerErrors/sparseSubdom-mismatch-1.chpl create mode 100644 test/domains/compilerErrors/sparseSubdom-mismatch-1.good create mode 100644 test/domains/compilerErrors/sparseSubdom-mismatch-2.chpl create mode 100644 test/domains/compilerErrors/sparseSubdom-mismatch-2.good diff --git a/test/domains/compilerErrors/rect-mismatch-type-1.chpl b/test/domains/compilerErrors/rect-mismatch-type-1.chpl new file mode 100644 index 000000000000..a00a52f7bee7 --- /dev/null +++ b/test/domains/compilerErrors/rect-mismatch-type-1.chpl @@ -0,0 +1,4 @@ +// related: test/arrays/deitz/part5/test_array_uint2.chpl + +var DnsStencDom = {-1:int(8)..1:int(8), -1:int(8)..1:int(8)}; +DnsStencDom = (-1..0, -1..0); // error: int8 <- int64 diff --git a/test/domains/compilerErrors/rect-mismatch-type-1.good b/test/domains/compilerErrors/rect-mismatch-type-1.good new file mode 100644 index 000000000000..122b8257ce39 --- /dev/null +++ b/test/domains/compilerErrors/rect-mismatch-type-1.good @@ -0,0 +1 @@ +rect-mismatch-type-1.chpl:4: error: index type mismatch in domain assignment diff --git a/test/domains/compilerErrors/sparseSubdom-mismatch-1.chpl b/test/domains/compilerErrors/sparseSubdom-mismatch-1.chpl new file mode 100644 index 000000000000..02d7d5705dbc --- /dev/null +++ b/test/domains/compilerErrors/sparseSubdom-mismatch-1.chpl @@ -0,0 +1,3 @@ +use List; +const dr = {1:int(8)..8:int(8)}; +const sd: sparse subdomain(dr) = new list(int); // error: int8 <- int64 diff --git a/test/domains/compilerErrors/sparseSubdom-mismatch-1.good b/test/domains/compilerErrors/sparseSubdom-mismatch-1.good new file mode 100644 index 000000000000..2ef0511e3e29 --- /dev/null +++ b/test/domains/compilerErrors/sparseSubdom-mismatch-1.good @@ -0,0 +1 @@ +sparseSubdom-mismatch-1.chpl:3: error: cannot add a int(64) to a sparse 1-dim domain with idxType int(8) diff --git a/test/domains/compilerErrors/sparseSubdom-mismatch-2.chpl b/test/domains/compilerErrors/sparseSubdom-mismatch-2.chpl new file mode 100644 index 000000000000..c0d3e0994ff9 --- /dev/null +++ b/test/domains/compilerErrors/sparseSubdom-mismatch-2.chpl @@ -0,0 +1,3 @@ + +const dr = {1:int(8)..8:int(8)}; +const sd: sparse subdomain(dr) = 2; // error: domain <- int diff --git a/test/domains/compilerErrors/sparseSubdom-mismatch-2.good b/test/domains/compilerErrors/sparseSubdom-mismatch-2.good new file mode 100644 index 000000000000..bd6eb0e16f7d --- /dev/null +++ b/test/domains/compilerErrors/sparseSubdom-mismatch-2.good @@ -0,0 +1 @@ +sparseSubdom-mismatch-2.chpl:3: error: assigning int(64) to an irregular domain From 206f501d9d2d02376700f360f6078905b1b621fb Mon Sep 17 00:00:00 2001 From: Vassily Litvinov Date: Thu, 7 Mar 2024 18:11:32 -0800 Subject: [PATCH 7/7] Adjust .bad files Signed-off-by: Vassily Litvinov --- test/expressions/if-expr/TernaryExpressionBugTwoIters.bad | 4 ++-- test/expressions/if-expr/if-loop-const.bad | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/expressions/if-expr/TernaryExpressionBugTwoIters.bad b/test/expressions/if-expr/TernaryExpressionBugTwoIters.bad index 7ce05522a3ee..5dae6754860c 100644 --- a/test/expressions/if-expr/TernaryExpressionBugTwoIters.bad +++ b/test/expressions/if-expr/TernaryExpressionBugTwoIters.bad @@ -1,4 +1,4 @@ TernaryExpressionBugTwoIters.chpl:1: In function 'test1': TernaryExpressionBugTwoIters.chpl:3: error: Unable to resolve type of if-expression -note: 'then' branch returns type "_ir_chpl__loopexpr_iter10" -note: 'else' branch returns type "_ir_chpl__loopexpr_iter11" +note: 'then' branch returns type "_ir_chpl__loopexpr_iter11" +note: 'else' branch returns type "_ir_chpl__loopexpr_iter12" diff --git a/test/expressions/if-expr/if-loop-const.bad b/test/expressions/if-expr/if-loop-const.bad index 9abe48ce49b7..37e6fa4aa380 100644 --- a/test/expressions/if-expr/if-loop-const.bad +++ b/test/expressions/if-expr/if-loop-const.bad @@ -1,4 +1,4 @@ if-loop-const.chpl:4: In function 'main': if-loop-const.chpl:8: error: Unable to resolve type of if-expression -note: 'then' branch returns type "_ir_chpl__loopexpr_iter10" -note: 'else' branch returns type "_ir_chpl__loopexpr_iter11" +note: 'then' branch returns type "_ir_chpl__loopexpr_iter11" +note: 'else' branch returns type "_ir_chpl__loopexpr_iter12"