Skip to content

Trace filter erases typed expect inside traced helper #1326

Description

@researchzero-sec

What Git revision are you using?

5538a42b

What operating system are you using, and which version?

  • Linux / Ubuntu
  • Linux / Other
  • macOS
  • Windows

Describe what the problem is?

A user trace wrapped around a helper call can erase a typed expect failure raised inside that helper when --trace-filter compiler-generated is used.

trace @"user trace": helper(bad_data()) behaves differently from helper(bad_data()) when the helper contains expect dat: MyDatum<Int> = d. Under --trace-filter compiler-generated, the plain helper call still fails and passes a fail test, but the traced helper call no longer reaches the typed expect failure, so the fail-marked test fails instead.

Reproduction:

use aiken/builtin

pub type MyDatum<a> {
  Constructor1(a)
  Constructor2
}

fn bad_data() -> Data {
  builtin.constr_data(0, [builtin.b_data(#"aa")])
}

fn helper(d: Data) -> Bool {
  expect dat: MyDatum<Int> = d

  when dat is {
    Constructor1(_) -> True
    _ -> False
  }
}

test plain_helper_typed_expect() fail {
  helper(bad_data())
}

test traced_helper_typed_expect() fail {
  trace @"user trace": helper(bad_data())
}

Running:

aiken check . --seed 1 --max-success 1 --trace-level verbose --trace-filter compiler-generated

plain_helper_typed_expect passes as an expected failure, while traced_helper_typed_expect fails the test. This extends the previously observed typed Data cast trace-filter behavior beyond a trace wrapped directly around the expect expression.

What should be the expected behavior?

--trace-filter compiler-generated should only filter which traces are emitted; it should not change evaluation semantics. The traced helper call (trace @"user trace": helper(bad_data())) should still reach the typed expect failure inside helper, so traced_helper_typed_expect should pass as an expected failure, matching the behavior of the plain helper(bad_data()) call in plain_helper_typed_expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    🪣 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions