internal: less generic-expression workarounds #821
Merged
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.
Summary
Prevent expressions-depending-on-unresolved-type-variables passed to
tryConstExpr
from reaching into the compile-time evaluation machinery.This allows for removing multiple workarounds from
mirgen
andvmgen
.Details
Before
tryConstExpr
passes the expression toevalConstExpr
, it nowfirst checks whether the expression either contains unresolved generic
parameters or is an unresolved type-parameter-lookup (e.g.,
T.param
).If either is the case,
nil
(which signals that the expression cannotbe evaluated at compile-time) is returned without passing the
expression to
evalConstExpr
.While this approach is fundamentally also a workaround (expressions
containing unresolved generic parameters shouldn't be passed to
tryConstExpr
in the first place), it at least prevents unresolvedexpressions from reaching into
transf
,mirgen
, andvmgen
.mirgen
now doesn't have to push unresolved generic parameters ortype-parameter-lookups as
mnkLiteral
s through the MIR phase, andvmgen
doesn't have to special-case them. More generally,vmgen
cannow treat unexpected nodes reaching it as a defect (via
unreachable
).Since
vmGenDiagCodeGenUnexpectedSym
andvmGenDiagCannotGenerateCode
are now unused, they are, together with everything related to them,
removed.