Skip to content

feat: add detector for incorrect memory-safe-assembly annotations#2973

Closed
ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
ep0chzer0:feat/invalid-memory-safe-assembly
Closed

feat: add detector for incorrect memory-safe-assembly annotations#2973
ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
ep0chzer0:feat/invalid-memory-safe-assembly

Conversation

@ep0chzer0
Copy link
Contributor

Summary

  • Addresses Enhancement: Detect Invalid Memory-Safe Assembly Annotations #2780 - Detects incorrect usage of the @solidity memory-safe-assembly annotation
  • The annotation only works in NatSpec comments (/// or /** */). Using it in regular comments (// or /* */) is silently ignored by the compiler, so expected memory optimizations are never applied.
  • Detector flags:
    • Regular single-line comments (// instead of ///)
    • Regular multi-line comments (/* */ instead of /** */)
    • Common misspellings in NatSpec annotations (e.g., memory-sage-assembly)

Test plan

  • Added test contract with 3 flagged cases and 4 non-flagged cases (correct NatSpec, no annotation, no assembly)
  • All 382 detector tests pass
  • Verified with ruff check and ruff format

The `@solidity memory-safe-assembly` annotation only works in NatSpec
comments (`///` or `/** */`). Using it in regular comments (`//` or
`/* */`) is silently ignored by the compiler.

This detector flags:
- Regular single-line comments with the annotation (// instead of ///)
- Regular multi-line comments with the annotation (/* */ instead of /** */)
- Common misspellings in NatSpec annotations

Addresses crytic#2780
@ep0chzer0 ep0chzer0 requested a review from smonicas as a code owner February 23, 2026 22:32
@ep0chzer0
Copy link
Contributor Author

Closing as duplicate - this issue is already addressed by #2943. Apologies for the duplicate.

@ep0chzer0 ep0chzer0 closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant