fix(typeck): reject non-path receivers for Vector/Mapping storage ops#29432
Merged
Conversation
a7aaa5f to
960affc
Compare
mitchmindtree
approved these changes
May 20, 2026
Collaborator
mitchmindtree
left a comment
There was a problem hiding this comment.
Left one optional suggestion, but lgtm! ![]()
| map_expr.span(), | ||
| )); | ||
| return Type::Err; | ||
| } |
Collaborator
There was a problem hiding this comment.
Looks like quite a few of these - I wonder we'd benefit from something like:
/// Returns `true` if `expr` is a path receiver; otherwise emits a diagnostic and returns `false`.
fn check_path_receiver(&self, module: &str, operation: &str, kind: &str, expr: &Expression) -> bool {
if matches!(expr, Expression::Path(_)) {
return true;
}
self.emit_err(crate::errors::type_checker::storage_op_requires_path_receiver(
module, operation, kind, expr.span(),
));
false
}
Collaborator
Author
There was a problem hiding this comment.
Good call, done. Extracted into a check_path_receiver helper.
5a98d21 to
8cc7db7
Compare
`Vector::{len,get,set,push,pop,swap_remove,clear}` and
`Mapping::{get,get_or_use,contains,set,remove}` assumed an
`Expression::Path` receiver downstream: storage_lowering for vectors,
codegen for mappings. Type-checking only verified the receiver's type.
- Read ops (`len`/`get`/`get_or_use`/`contains`) had no path check at
all, so a ternary of two storage vectors ICEd in storage_lowering
(#29428) and a ternary of two mappings produced invalid bytecode that
failed late at disassembly.
- Write ops already had an `is_local_path` check, but emitted the
"external vectors/mappings" diagnostic for a local ternary receiver,
which is misleading.
Add an `Expression::Path` pre-check to all eleven arms and emit a new
`ETYC0372191` for non-path receivers. The existing
"external vectors/mappings" diagnostic now only fires when the receiver
is an actual external path, which is what its wording describes.
Fixes #29428.
8cc7db7 to
a9bc243
Compare
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.
Summary
Vector::{len,get,set,push,pop,swap_remove,clear}andMapping::{get,get_or_use,contains,set,remove}assume anExpression::Pathreceiver downstream (storage_lowering for vectors, codegen for mappings), but type-checking only verified the receiver's type.is_local_pathcheck, but emitted the "external vectors/mappings" diagnostic for a local ternary receiver, which is misleading.Expression::Pathpre-check to all eleven arms and emit a newETYC0372191. The existing "external" diagnostic now only fires when the receiver is an actual external path.Fixes #29428.