Skip to content

Commit

Permalink
Fix Diagnostic Assertion Macros (#43)
Browse files Browse the repository at this point in the history
## What Changed?

In had the conditions wrong in the assertion macros. Also now they
accept an optional trailing `,` in accordance with the typical macro
behavior of e.g. `print`.

## Why Does It Need To?

The assertion macros were unintuitive.

## Checklist

- [x] Above description has been filled out so that upon quash merge we
have a
  good record of what changed.
- [x] New functions, methods, types are documented. Old documentation is
updated
  if necessary
- [x] Documentation in Notion has been updated
- [x] Tests for new behaviors are provided
  - [x] New test suites (if any) ave been added to the CI tests (in
`.github/workflows/rust.yml`) either as compiler test or integration
test.
*Or* justification for their omission from CI has been provided in this
PR
    description.
  • Loading branch information
JustusAdam authored Sep 18, 2023
1 parent 70ca09a commit eb2f2a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/dfcheck/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type FlowsTo = HashMap<Identifier, CtrlFlowsTo>;
/// Check the condition and emit a [`Context::error`] if it fails.
#[macro_export]
macro_rules! assert_error {
($ctx:expr, $cond: expr, $msg:expr) => {
if $cond {
($ctx:expr, $cond: expr, $msg:expr $(,)?) => {
if !$cond {
$ctx.error($msg);
}
};
Expand All @@ -34,8 +34,8 @@ macro_rules! assert_error {
/// Check the condition and emit a [`Context::warning`] if it fails.
#[macro_export]
macro_rules! assert_warning {
($ctx:expr, $cond: expr, $msg:expr) => {
if $cond {
($ctx:expr, $cond: expr, $msg:expr $(,)?) => {
if !$cond {
$ctx.warning($msg);
}
};
Expand Down

0 comments on commit eb2f2a0

Please sign in to comment.