Skip to content

Conversation

@benharsh
Copy link
Member

@benharsh benharsh commented Dec 8, 2025

This PR utilizes information from the frontend resolver to generate converted AST for implicitly initialized fields. Implicitly initialized fields in branches will be addressed in future PRs. This effort required some modifications to the frontend:


Split 'resolveFieldDecl` to store results separately

This PR splits out some of the logic in resolveFieldDecl so that we can re-query and fetch the RRBPID later. This new query is called resolveFieldResults, and returns a type introduced by this commit called ResolvedFieldResults. This new type primarily stores the RRBPID computed by a Resolver, but also stores some useful information alongside the resolution results.

A convenience query, called resolvedFieldsFromResults, that can be combined with resolveFieldResults to achieve the same output as resolveFieldDecl.

This PR also fixes a minor bug when initializing the ResolvedFields structure. Previously the given RRBPID was not const, so invoking 'byAst' would create an empty entry. Instead, we check if we're in syntaxOnly mode, in which case there will not be results and we should instead create an unknown QualifiedType.


Store implicit initialization information in ResolvedFunction

This PR adds key data about implicitly initialized fields within an initializer, to be used later during typed conversion. Initially this information is a basic map of IDs before which the fields should be initialized, but will likely need to evolve to handle more complex cases related to e.g., branching. Currently, an empty ID indicates that the fields need to be initialized at the end of the initializer.

InitResolver is udpated to collect this information, which is then requested upon creation of the ResolvedFunction.


Testing:

  • test/frontend/
  • test-dyno
  • --dyno-resolve-only
  • normal paratest

This commit splits out some of the logic in ``resolveFieldDecl`` so that
we can re-query and fetch the RRBPID later. This new query is called
``resolveFieldResults``, and returns a type introduced by this commit
called ``ResolvedFieldResults``. This new type primarily stores the
RRBPID computed by a Resolver, but also stores some useful information
alongside the resolution results.

A convenience query, called ``resolvedFieldsFromResults``, that can be
combined with ``resolveFieldResults`` to achieve the same output as
``resolveFieldDecl``.

This commit also fixes a minor bug when initializing the ``ResolvedFields``
structure. Previously the given RRBPID was not const, so invoking
'byAst' would create an empty entry. Instead, we check if we're in
``syntaxOnly`` mode, in which case there will not be results and we
should instead create an unknown QualifiedType.

Signed-off-by: Ben Harshbarger <[email protected]>
Signed-off-by: Ben Harshbarger <[email protected]>
This commit adds key data about implicitly initialized fields within an
initializer, to be used later during typed conversion. Initially this
information is a basic map of IDs before which the fields should be
initialized, but will likely need to evolve to handle more complex cases
related to e.g., branching. Currently, an empty ID indicates that the
fields need to be initialized at the end of the initializer.

InitResolver is udpated to collect this information, which is then
requested upon creation of the ResolvedFunction.

Signed-off-by: Ben Harshbarger <[email protected]>
This commit utilizes information from the frontend resolver to generate
converted AST for implicitly initialized fields.

Such cases as they relate to branching are left as future work.

Signed-off-by: Ben Harshbarger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant