dotnet / dotnet/fsharp

Rethink how names are given to compiler-generated closures

Open
#12,366 9 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-CodeGen Feature Improvement Needs-design Theme-Simple-F#
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

The heuristic used to name compiler-generated closures like `foo@376` and `clo43@53` is weak. In general the compiler tries to use a related name, e.g. the `let` identifier being bound, plus the source line number. The source line number seems to be useful, though we could perhaps use `@line365` or similar.

The main problem appears to be with the name portion. I need to collect specific micro samples but some things I've noticed are

* Unnecessary use of the backup name `clo`
* Sometimes other compiler-generated names are used as the basis for the name. In debug code I've even seen closure names like `Pipe input at line 63@53` recently after the addition of pipeline debugging and I think some are appearing in our codegen tests for queries

Anyway, we can surely have a better heuristic where useful names are always given.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.