diff options
author | Marijn Suijten <[email protected]> | 2021-01-03 16:45:49 +0000 |
---|---|---|
committer | Marijn Suijten <[email protected]> | 2021-01-04 09:55:09 +0000 |
commit | d33edb4e9cf1cad1c9ceb7c99859d73993ccba29 (patch) | |
tree | 84b93a8b3aa2c1c4e8c17fe72988b2270c80c331 /crates/toolchain/src | |
parent | b87699d97ac34f95dc09d166d07fc1220b460821 (diff) |
ssr: Allow replacing expressions with statements
Now that statements can be matched and replaced (#6587) some usecases
require expressions to be replaced with statements as well. This happens
when something that can ambiguously be an expression or statement like
`if` and loop blocks appear in the last position of a block, as trailing
expression. In this case a replacement pattern of the form `if
foo(){$a();}==>>$a();` will only substitute `if` blocks in the list of
statements but not if they (implicitly) end up in the trailing
expression, where they are not wrapped by an EXPR_STMT (but the pattern
and template are, as parsing only succeeds for the `stmt ==>> stmt`
case).
Instead of adding two rules that match an expression - and emit
duplicate matching errors - allow the template for expressions to be a
statement if it fails to parse as an expression.
Diffstat (limited to 'crates/toolchain/src')
0 files changed, 0 insertions, 0 deletions