Skip to content

Conversation

@bogdan-stacks
Copy link

This PR adds a clarity-wasm feature flag for certain Clarity1 errors as the WASM and interpreter error behaviors differ slightly, even though they represent the same underlying meaning.

Closes: stx-labs/clarity-wasm#702

@bogdan-stacks bogdan-stacks requested a review from a team as a code owner December 1, 2025 16:36
@bogdan-stacks bogdan-stacks changed the title add feature flag for specific errors Fix wasm-issue#702 add feature flag Dec 1, 2025
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.56%. Comparing base (6e2efe2) to head (2039514).

Files with missing lines Patch % Lines
stackslib/src/chainstate/stacks/db/transactions.rs 0.00% 26 Missing ⚠️

❌ Your project check has failed because the head coverage (29.56%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/clarity-wasm-develop    #6726      +/-   ##
=============================================================
- Coverage                      30.91%   29.56%   -1.35%     
=============================================================
  Files                            572      572              
  Lines                         358768   358775       +7     
=============================================================
- Hits                          110903   106083    -4820     
- Misses                        247865   252692    +4827     
Files with missing lines Coverage Δ
stackslib/src/chainstate/stacks/db/transactions.rs 5.47% <0.00%> (+0.03%) ⬆️

... and 119 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e2efe2...2039514. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +9555 to +9560
if let Error::ClarityError(clarity_error::Wasm(WasmError::WasmGeneratorError(_))) = &err
{
// WASM error type - expected in WASM context
} else {
panic!("Did not get unchecked interpreter error or WASM generator error");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would certainly be cleaner using a matches!.

Comment on lines +9554 to +9564
#[cfg(feature = "clarity-wasm")]
if let Error::ClarityError(clarity_error::Wasm(WasmError::WasmGeneratorError(_))) = &err
{
// WASM error type - expected in WASM context
} else {
panic!("Did not get unchecked interpreter error or WASM generator error");
}
#[cfg(not(feature = "clarity-wasm"))]
{
panic!("Did not get unchecked interpreter error");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the cfg! macro would certainly make the distinction cleaner for the future readers.

Comment on lines +9667 to +9677
#[cfg(feature = "clarity-wasm")]
if let Error::ClarityError(clarity_error::Wasm(WasmError::WasmGeneratorError(_))) = &err
{
// WASM error type - expected in WASM context
} else {
panic!("Did not get unchecked interpreter error or WASM generator error");
}
#[cfg(not(feature = "clarity-wasm"))]
{
panic!("Did not get unchecked interpreter error");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Comment on lines +9745 to +9753
if cfg!(feature = "clarity-wasm") {
assert!(err_str
.find("TypeError(CallableType(Trait(TraitIdentifier")
.is_some());
} else {
assert!(err_str
.find("TypeValueError(OptionalType(CallableType(Trait(TraitIdentifier")
.is_some());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the procedure is identical with both features, how about having a variable that would contain the expected error string, and then call assert!(err_str.find(expected_err).is_some()).

Comment on lines +9747 to +9748
.find("TypeError(CallableType(Trait(TraitIdentifier")
.is_some());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str::contains would be more explicit.

Comment on lines +9769 to +9773
if cfg!(feature = "clarity-wasm") {
assert_eq!(acct.nonce, 4);
} else {
assert_eq!(acct.nonce, 5);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here also, the procedure is equivalent, we can just move the if cfg!(...) {...} else {...} inside the assert_eq!.

Comment on lines +9784 to +9786
assert!(err_str
.find("TypeValueError(OptionalType(CallableType(Trait(TraitIdentifier ")
.is_some());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as above.

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.

2 participants