Fix return type checking to allow aliasing for non-ephemeral return types. #3201
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes return type checking to allow aliasing for non-ephemeral return types.
I discovered this type system issue after a discussion with @rkallos in which we discussed how to fix
Map.insert
(and others) to not have an unreachable error case.Looking into it further, I discovered that the type system had a simple bug that wasn't obvious due to the inconsistency in how Pony handles return type checking (the fact that using the ephemeral modifier is required to describe a unique return type, whereas on all other type specifications, the ephemeral modifier is useless).
This PR doesn't address that inconsistency, because it would be a major breaking change for the language, but this does fix the small bug that went unnoticed because of it.
The bug can be reproduced with the following code, in which
get_1
andget_2
are valid and functionally identical, but the latter fails to compile:Upon investigation, it turned out to be a simple boolean logic bug, in which
not (A or B)
was expressed as!a || !b
instead of the correct!a && !b
. The code comment several lines above the change expresses the intended meaning, so I know that this fixed logic reflects the code author's original intent.