Repository navigation
An inherited default method's body is checked by the function-body check (#3360) - #3382
Merged
Merged
Conversation
…eck: check_body_under_return is the one owner of the tail's context, the drops at the body's end, move-site liveness and the returned tail (a T tail under Option[T] works; a returned view of an owned parameter is refused) (#3360)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3360.
SemaCheck.check_trait_default_method_body_for_implchecked a default body with a smaller copy of the function-body check. The part ofcheck_fn_body_with_sig_oncethat checks a body under its return demand is now one method,check_body_under_return, with two callers (D65: one owner): the tail's context (D43, §4.9a), the drops at the body's end (#1827), move-site liveness, and what the returned tail does (check_body_result: field moves, effects, view origins).begin_body_bindingsreplaces three copies of the same two lines.What changes for programs:
Ttail underOption[T]in a default method isSome(was "the function returnsOption[i32], this value isi32"):test/behavior/behav_3360_default_method_option_tail.w;test/compile_errors/err_3360_default_method_returns_view_of_owned_param.w.Both tests fail before the change. The 68 existing tests with
defaultin their name pass with the dev compiler.Battery GREEN (3638d6e);
:release-checksgreen.