Branch: refs/heads/main
Revision: a9e69bd8bceff613d0f1c56e22b92a4d1668b107
Author: DanilaFe
Link: dyno: fix casting param values to non-param values by DanilaFe · Pull Request #24878 · chapel-lang/chapel · GitHub
Log Message:
dyno: fix casting param values to non-param values (#24878)
This came up while trying out LSP with the resolver enabled. Resolving
IO.chpl caused assertion failures because we tried to infer the 'param
type' of byteIndex
. The apparent reason is that we were trying to cast
a param
-known value to a regular old non-param
type. Dyno code
assumed that if the value being cast is a param
, then the cast itself
is necessarily compile-time as well; this is inaccurate, since I should
be able to execute value-level casts on literals, like 0 : byteIndex
.
This PR adds a new static method on Param
to try guess the param
tag of a type, without asserting if the tag is not found. It returns an
optional. Then, the special handler for param
casting can call this
method, observe that the destination is not param
-enabled, and fall
back to regular value-level calls.
While there, fix another bug in which we attempt to pass nullptr
to
->toRecordType
; this was hit shortly after the param cast.
Reviewed by @benharsh -- thanks!
Testing
- dyno tests
- paratest
Diff:
M frontend/include/chpl/types/Param.h
M frontend/lib/resolution/copy-elision.cpp
M frontend/lib/resolution/resolution-queries.cpp
M frontend/lib/types/Param.cpp
M frontend/test/resolution/testCast.cpp
https://github.com/chapel-lang/chapel/pull/24878.diff