Skip to content

Commit

Permalink
Fixed null check and default case
Browse files Browse the repository at this point in the history
  • Loading branch information
mjayasim9 committed Aug 1, 2023
1 parent 14cfea9 commit def7a8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ class SignalWidthMismatchException extends RohdException {
/// Constructs a new [Exception] for when a dynamic has no width or it could
/// not be inferred.
SignalWidthMismatchException.forNull(dynamic val)
: super('Could not infer width of value $val.'
: super('Could not infer width of input $val.'
' Please provide a valid width.');
}
10 changes: 5 additions & 5 deletions lib/src/modules/conditional.dart
Original file line number Diff line number Diff line change
Expand Up @@ -923,16 +923,16 @@ Logic cases(Logic expression, Map<dynamic, dynamic> conditions,

width ??= inferredWidth;

if (width == null && inferredWidth == null) {
throw SignalWidthMismatchException.forNull(conditionValue);
}

if (width != inferredWidth && inferredWidth != null) {
throw SignalWidthMismatchException.forDynamic(
conditionValue, width!, inferredWidth);
}
}

if (width == null) {
throw SignalWidthMismatchException.forNull(conditions);
}

for (final condition in conditions.entries) {
if (condition.key is Logic) {
if (expression.width != (condition.key as Logic).width) {
Expand Down Expand Up @@ -963,7 +963,7 @@ Logic cases(Logic expression, Map<dynamic, dynamic> conditions,
[result < condition.value])
],
conditionalType: conditionalType,
defaultItem: defaultValue != null ? [result < defaultValue] : [])
defaultItem: defaultValue != null ? [result < defaultValue] : null)
]);

return result;
Expand Down

0 comments on commit def7a8a

Please sign in to comment.