Describe the bug
LogicValue.toRadixString can produce a string that ofRadixString cannot read when both receive the same separator. Empty separators are accepted by the formatter but rejected by the parser; closing brackets and backslashes are interpolated into the parser's regular expression instead of being treated literally.
To Reproduce
import 'package:rohd/rohd.dart';
void main() {
final value = LogicValue.ofInt(39, 10);
for (final separator in ['', ']', r'\', '_']) {
final encoded = value.toRadixString(sepChar: separator);
try {
print('$encoded -> ${LogicValue.ofRadixString(encoded, sepChar: separator)}');
} catch (error) {
print('$encoded -> $error');
}
}
}
Expected behavior
Each formatted value round-trips when its separator is passed to the parser. _ already works.
Actual behavior
- Empty separator:
LogicValueConstructionException: separation character invalid.
]: LogicValueConstructionException: radix string stopped parsing at character position 5.
- Backslash:
FormatException: Unterminated character class.
Environment
Windows, Dart 3.13.4, current main d22fe80eb38241b524539ccbb9d6bd9842c943d3, ROHD 0.6.11.
Additional context
A local fix treats the separator literally using RegExp.escape and accepts an empty separator consistently with the formatter. Three new round-trip cases fail before and pass afterward; controls cover other punctuation separators, all five supported radices, and four-state values for non-decimal radices. The two LogicValue test modules pass all 181 tests. The full suite requires Icarus Verilog, which is unavailable locally. Investigation and validation used OpenAI Codex assistance.
Describe the bug
LogicValue.toRadixStringcan produce a string thatofRadixStringcannot read when both receive the same separator. Empty separators are accepted by the formatter but rejected by the parser; closing brackets and backslashes are interpolated into the parser's regular expression instead of being treated literally.To Reproduce
Expected behavior
Each formatted value round-trips when its separator is passed to the parser.
_already works.Actual behavior
LogicValueConstructionException: separation character invalid.]:LogicValueConstructionException: radix string stopped parsing at character position 5.FormatException: Unterminated character class.Environment
Windows, Dart 3.13.4, current main
d22fe80eb38241b524539ccbb9d6bd9842c943d3, ROHD 0.6.11.Additional context
A local fix treats the separator literally using
RegExp.escapeand accepts an empty separator consistently with the formatter. Three new round-trip cases fail before and pass afterward; controls cover other punctuation separators, all five supported radices, and four-state values for non-decimal radices. The two LogicValue test modules pass all 181 tests. The full suite requires Icarus Verilog, which is unavailable locally. Investigation and validation used OpenAI Codex assistance.