Skip to content

Conversation

@stevennevins
Copy link

@stevennevins stevennevins commented Dec 5, 2025

Summary

CR mutator now uses block comments (/* */) instead of line comments (//).

Problem

Line comment // comments out everything after it on the line. This breaks compilation when code continues:

// Original
function test() public onlyOwner {

// With // - BROKEN
function test() public // onlyOwner {

// With /* */ - WORKS  
function test() public /* onlyOwner */ {

Solution

new_str = "/* " + old_str + " */"

Scenarios Improved

Function modifier same line as brace:

// Original
function foo() onlyOwner {

// Before (broken)
function foo() // onlyOwner {

// After (works)
function foo() /* onlyOwner */ {

Single-line functions:

// Original
function getX() view returns (uint) { return x; }

// Before (broken) - commenting return statement
function getX() view returns (uint) { // return x; }

// After (works)
function getX() view returns (uint) { /* return x; */ }

Line comments (//) break compilation when code continues after the
commented portion on the same line. Block comments (/* */) work in
all cases.

Also include trailing semicolon in comment when present, preventing
orphaned semicolon syntax errors like `/* stmt */;`.
@stevennevins stevennevins force-pushed the fix/cr-mutator-block-comments-v2 branch from c7ae8ab to f6bacf4 Compare December 5, 2025 15:10
@stevennevins stevennevins marked this pull request as ready for review December 11, 2025 21:39
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