Branch: refs/heads/master
Revision: 05575d1
Author: mppf
Log Message:
Merge pull request #17092 from mppf/errors-conversion-levels
Add compilation error for missing implied conversions
This is philisophically a continuation of PR #14956. Issue #15838
contains design discussion.
This PR adds compilation errors according to an idea that conversions
between types come in 4 levels. The idea is that a programmer should be
able to access any of these 4 levels, but the higher levels imply the
lower ones.
- level 4 (implicit conversion) implies 3,2,1 (assign, initialize, cast)
- level 3 (assign) implies 2,1 (initialize, cast)
- level 2 (initialize) implies 1 (cast)
- level 1 (cast) doesn’t imply any of the others
To support that idea, this PR adds errors for
- no
init=
between two types when=
is present - no cast between two types when
init=
is present.
For now this PR uses the existing proc _cast(type t: toType, other: fromType)
syntax to declare the casts. That is so that it does not
interfere ongoing changes to operators.
Additionally, because it’s not currently possible to declare tertiary
initializers or initializers on extern
types, this PR leaves out the
missing init=
error for these types for now.
For https://github.com/Cray/chapel-private/issues/1626
Reviewed by @lydia-duncan - thanks!
- [x] full local futures testing
Modified Files:
A test/functions/operatorOverloads/operatorMethods/genericsInstantiationBad.prediff
A test/types/records/ferguson/missing-functions/assign-other-type-no-cast.chpl
A test/types/records/ferguson/missing-functions/assign-other-type-no-cast.good
A test/types/records/ferguson/missing-functions/assign-other-type-no-copy-init-cast.chpl
A test/types/records/ferguson/missing-functions/assign-other-type-no-copy-init-cast.good
A test/types/records/ferguson/missing-functions/assign-other-type-no-copy-init.chpl
A test/types/records/ferguson/missing-functions/assign-other-type-no-copy-init.good
A test/types/records/ferguson/missing-functions/assign-other-type-ok.chpl
A test/types/records/ferguson/missing-functions/assign-other-type-ok.good
A test/types/records/ferguson/missing-functions/cast-other-type-ok.chpl
A test/types/records/ferguson/missing-functions/cast-other-type-ok.good
A test/types/records/ferguson/missing-functions/init-other-type-no-cast.chpl
A test/types/records/ferguson/missing-functions/init-other-type-no-cast.good
A test/types/records/ferguson/missing-functions/init-other-type-ok.chpl
A test/types/records/ferguson/missing-functions/init-other-type-ok.good
A test/types/records/ferguson/missing-functions/overload-assign-array.chpl
A test/types/records/ferguson/missing-functions/overload-assign-array.good
A test/types/records/ferguson/missing-functions/overload-assign-tuple.chpl
A test/types/records/ferguson/missing-functions/overload-assign-tuple.good
M compiler/main/checks.cpp
M compiler/resolution/resolveFunction.cpp
M modules/internal/Atomics.chpl
M modules/internal/Bytes.chpl
M modules/internal/ChapelSyncvar.chpl
M modules/internal/SharedObject.chpl
M modules/standard/IO.chpl
M modules/standard/List.chpl
M test/classes/bradc/compilerErrorInMethod/testClear-snap1.chpl
M test/classes/bradc/compilerErrorInMethod/testClear-snap2.chpl
M test/classes/bradc/compilerErrorInMethod/testClear-workaround.chpl
M test/classes/bradc/compilerErrorInMethod/testClear.bad
M test/classes/bradc/compilerErrorInMethod/testClear.chpl
M test/classes/bradc/compilerErrorInMethod/testClear2.chpl
M test/classes/delete-free/bug-375.good
M test/classes/initializers/initequals/basic.chpl
M test/classes/initializers/initequals/changing-param-field.chpl
M test/classes/initializers/initequals/generics.chpl
M test/classes/initializers/initequals/temp-destroyed.chpl
M test/classes/initializers/initequals/vector.chpl
M test/demo/review_060130/history_accumulator.chpl
M test/functions/deitz/test_assign1.chpl
M test/functions/operatorOverloads/operatorMethods/genericsInstantiationBad.good
M test/functions/sungeun/procEqualsExternType.chpl
M test/functions/vass/declaredGenericReturnTuple.bad
M test/library/draft/Vector/Vector.chpl
M test/types/partial/initeq.chpl
M test/types/records/ferguson/init-eq-other-only.chpl
M test/types/records/ferguson/init-eq-other-only.good
M test/types/tuple/ranges/tupleOfRanges.bad
M test/types/tuple/split-init/splitInitRecordViaTuple.chpl
M test/types/type_variables/deitz/part7/test_tuplelike1.chpl
Compare: Comparing 76097352e7de...05575d1454c6 · chapel-lang/chapel · GitHub