[Chapel Merge] Fix a bug with lambdas in generic functions (#2028

Branch: refs/heads/main
Revision: c7a8e6f
Author: dlongnecke-cray
Link: Unavailable
Log Message:

Merge pull request #20287 from dlongnecke-cray/issue-20046

Fix a bug with lambdas in generic functions (#20287)

Resolves #20046.

Fix a bug which caused nested lambdas defined in generic functions
to issue an internal compiler error.

The function which lowers first class functions calls the helper
getVisibleFunctions in order to make sure that the number of
candidates for a function is exactly one.

However getVisibleFunctions does not rebuild the visible functions
map after instantiation occurs. This presented a scenario where
a FCF created in an instantiated function failed to find any
candidates for the underlying function call.

Expose recomputeVisibleFunctions that can be called manually in
createFunctionAsValue (it is normally called in the process of
finding candidates for a call using findVisibleFunctions).

Reviewed by @lydia-duncan, @vasslitvinov. Thanks!


  • ALL on linux64, standard

Signed-off-by: David Longnecker dlongnecke-cray@users.noreply.github.com

Modified Files:
A test/functions/firstClassFns/NestedLambdaInGenericFn.chpl

A test/functions/firstClassFns/NestedLambdaInGenericFn.good
M compiler/include/visibleFunctions.h
M compiler/resolution/preFold.cpp
M compiler/resolution/visibleFunctions.cpp

Compare: https://github.com/chapel-lang/chapel/compare/3dd45ecf818e...c7a8e6f29604