Skip to content

Commit

Permalink
feat: check placeholders inside unchecked blocks (#172)
Browse files Browse the repository at this point in the history
* feat/check-placeholders-inside-unchecked

* fix
  • Loading branch information
TilakMaddy authored Dec 16, 2024
1 parent e321f62 commit 13d4e71
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/sema/src/ast_passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ impl<'ast> Visit<'ast> for AstValidator<'_, 'ast> {
.span(stmt.span)
.emit();
}
if self.in_unchecked_block {
self.dcx()
.err("placeholder statements cannot be used inside unchecked blocks")
.span(stmt.span)
.emit();
}
}
_ => {}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/resolve/placeholder_unchecked.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
contract A {
modifier xrp() {
unchecked {
_; //~ERROR: placeholder statements cannot be used inside unchecked blocks
}
}

constructor() {}
}
9 changes: 9 additions & 0 deletions tests/ui/resolve/placeholder_unchecked.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error: placeholder statements cannot be used inside unchecked blocks
--> ROOT/tests/ui/resolve/placeholder_unchecked.sol:LL:CC
|
LL | _;
| ^^
|

error: aborting due to 1 previous error

0 comments on commit 13d4e71

Please sign in to comment.