Branch: refs/heads/main
Revision: d205c97
Author: vasslitvinov
Link: Avoid duplicate calls in the return expression by vasslitvinov · Pull Request #19682 · chapel-lang/chapel · GitHub
Log Message:
Merge pull request #19682 from vasslitvinov/fix-dup-ret-call
Avoid duplicate calls in the return expression
Resolves #19674.
Given a function with an explicit array return type and
a return expression like return someFunCall();
,
have the compiler normalize the result of someFunCall() into a call temp
and pass that temp into insertDomainCheck() and insertElementTypeCheck().
Before this change, normalization would pass a copy of the AST for someFunCall()
into insertDomainCheck() and insertElementTypeCheck(), resulting in
duplicate calls to someFunCall() in the AST and at run time.
Related/background: []
, [] someType
and [1..10]
can be used as generic
array types where a function return type is expected. However they cannot
be used as standalone types. This justifies the special case for these
in normalization.
r: @mppf
Modified Files:
A test/arrays/return/double-call-bug.chpl
A test/arrays/return/double-call-bug.good
M compiler/passes/normalize.cpp
Compare: https://github.com/chapel-lang/chapel/compare/f5a0d97ca834...d205c979a37e