fix double-free and compiler crash #1414
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
sink
parameters ofinstantiated generic tuple type
seq
,array
, orset
construction to a generic instantiation receiver type
Fixes #1415.
Details
Post-match fitting didn't consider generic tuple instantiations when
applying implicit conversions, meaning that the
nkHiddenSubConv
ornkHiddenStdConv
inserted earlier bysigmatch
stayed.This led to two issues:
nkStmtListExpr
s of empty container type didn't have their typesfixed properly, causing crashes when the empty type reached into the
MIR phase
sink T
andT
is considered an rvalueconversion by
proto_mir
, which resulted in assignments involvingthese implicit conversions effectively being shallow assignments
(and thus double frees)
Skipping
tyGenericInst
andtyAlias
(for good measure) makes surethe implicit conversion is collapsed when the destination type is a
generic instantiation, fixing both issues. A test is added for both.