Repository navigation
Merged
Conversation
…emands (#959, D165) `str` had no parse method: `f[1].parse()` was "unknown method 'parse' for type '&str'", so a field could not become a number. `parse[T: Parse]() -> Option[T]` takes its type from its use, as Eric set in the #2127 review. Two Sema gaps stood in the way (the third, the `??` carrier hint, landed as #2724): - check_generic_method_call returned before checking a generic method of a builtin owner (`type_decl_nodes` has no `str`), so the call reached MIR uninstantiated. A builtin owner now has no type parameters of its own. - a method type parameter no argument mentions was never bound from the demand on the result, so `let n: Option[i64] = cell.get()` was "cannot infer generic method type parameter". It is now, as for a free generic function. Parsing is strict (None unless the whole text is one in-range value): the integer types parse sign and digits; f64 validates the text and reads strtold's correctly rounded double through rt_core. f32 waits for its own correctly rounded parse. Landing str.parse broke `text |> parse` pipelines naming a program's own `fn parse` (behav_pipeline_match, spec_ss09_7_pipeline_match): check_pipeline committed to a method on existence alone, bound str.parse[T], and died "cannot infer 'T'". A generic method is now applicable at a stage only when the stage can instantiate it (§9.6, D165): every type parameter named by a parameter type, or bound by the demand on the stage's result (asked speculatively, substitution restored). Otherwise, when a visible free function shares the name, the stage is that function. Verified matrix: demand-bound stage takes the method, undemanded stage takes the program's parse, no free function keeps the loud cannot-infer error, `parse[i64]()` spells it. The census rise that parked the branch was its own ceremony: sixteen `Some(...)` wrappers at Option demands in the new string.w code (now bare values, D103) and two typed field lets in the new Sema code (now inferred). Counts return to main's (plain-bits 416, the D144 allowance ceiling; some-at lib 1, src 7). Tests: behav_959_str_parse_by_use, behav_959_generic_method_typed_by_result (both fail pre-fix on the installed compiler); the two pipeline_match fixtures are the collision regression. Delegated under D98 as D165 (renumbers the unmerged fix-959 branch's D160).
This was referenced Oct 27, 2026
Contributor
Author
|
Battery GREEN on the stack top |
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.
std, Sema: str.parse() turns text into a number of the type its use demands (#959, D165)
strhad no parse method:f[1].parse()was "unknown method 'parse'for type '&str'", so a field could not become a number.
parse[T: Parse]() -> Option[T]takes its type from its use, as Eric set in the#2127 review. Two Sema gaps stood in the way (the third, the
??carrier hint, landed as #2724):
of a builtin owner (
type_decl_nodeshas nostr), so the callreached MIR uninstantiated. A builtin owner now has no type parameters
of its own.
the demand on the result, so
let n: Option[i64] = cell.get()was"cannot infer generic method type parameter". It is now, as for a free
generic function.
Parsing is strict (None unless the whole text is one in-range value):
the integer types parse sign and digits; f64 validates the text and
reads strtold's correctly rounded double through rt_core. f32 waits for
its own correctly rounded parse.
Landing str.parse broke
text |> parsepipelines naming a program'sown
fn parse(behav_pipeline_match, spec_ss09_7_pipeline_match):check_pipeline committed to a method on existence alone, bound
str.parse[T], and died "cannot infer 'T'". A generic method is now
applicable at a stage only when the stage can instantiate it (§9.6,
D165): every type parameter named by a parameter type, or bound by the
demand on the stage's result (asked speculatively, substitution
restored). Otherwise, when a visible free function shares the name, the
stage is that function. Verified matrix: demand-bound stage takes the
method, undemanded stage takes the program's parse, no free function
keeps the loud cannot-infer error,
parse[i64]()spells it.The census rise that parked the branch was its own ceremony: sixteen
Some(...)wrappers at Option demands in the new string.w code (nowbare values, D103) and two typed field lets in the new Sema code (now
inferred). Counts return to main's (plain-bits 416, the D144 allowance
ceiling; some-at lib 1, src 7).
Tests: behav_959_str_parse_by_use, behav_959_generic_method_typed_by_result
(both fail pre-fix on the installed compiler); the two pipeline_match
fixtures are the collision regression. Delegated under D98 as D165
(renumbers the unmerged fix-959 branch's D160).