Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on == in &convert for a bitfield member #1664

Closed
J-Gras opened this issue Jan 26, 2024 · 0 comments · Fixed by #1729
Closed

Error on == in &convert for a bitfield member #1664

J-Gras opened this issue Jan 26, 2024 · 0 comments · Fixed by #1729
Assignees
Labels
Bug Something isn't working

Comments

@J-Gras
Copy link
Contributor

J-Gras commented Jan 26, 2024

Reproducer:

module Test;

public type Foo = unit {
    x: bitfield(8) {
        a: 0..3 &convert=($$ == 2);
        b: 4..7;
    };

    on %done { print self; }
};

The above fails with:

/private/var/folders/lg/j_sk2y597mg6st_cnvclzxjw0000gn/T/Test_9cf8fb46577f0273-dec2483ac1f988d9.cc:99:70: error: no viable overloaded '='
    std::tie(::hilti::rt::optional::valueOrInit((*__self).x), __cur) = (__x_1 = ::hilti::rt::integer::unpack<uint8_t>(__cur, ::hilti::rt::ByteOrder{::hilti::rt::ByteOrder::Network}), hilti::rt::make_result(std::make_tuple(hilti::rt::make_bitfield((hilti::rt::integer::bits(std::get<0>(*__x_1), 0, 3, ::hilti::rt::integer::BitOrder{::hilti::rt::integer::BitOrder::LSB0}) == ::hilti::rt::integer::safe<std::uint8_t>{2U}), hilti::rt::integer::bits(std::get<0>(*__x_1), 4, 7, ::hilti::rt::integer::BitOrder{::hilti::rt::integer::BitOrder::LSB0}), hilti::rt::integer::noop(std::get<0>(*__x_1))), std::get<1>(*__x_1)))).valueOrThrow();
...

Something like &convert=($$ + 2) works fine for me.

@bbannier bbannier added the Bug Something isn't working label Jan 26, 2024
@rsmmr rsmmr self-assigned this Apr 29, 2024
rsmmr added a commit that referenced this issue Apr 29, 2024
Turns out #1664 was only indirectly related to the `&convert` itself;
the real issue was that we couldn't assign one bitfield struct to
another if their field types didn't match exactly, even in cases where
at the C++ level there was no meaningful difference. In this case we
ended up with a field that had a C++ type `rt::Bool` in one type and
`bool` in another, leading to errors when assigning the latter to the
former. We now allow to creating instances of the former from the
latter through standard C++ type conversions on a per field basis.

Closes #1664.
@bbannier bbannier linked a pull request Apr 29, 2024 that will close this issue
@rsmmr rsmmr closed this as completed in 14437ab May 6, 2024
rsmmr added a commit that referenced this issue May 6, 2024
…vert'

* origin/topic/robin/gh-1664-bitrange-convert:
  Fix `&convert` typing issue with bit ranges.
  Suppress new clang-tidy warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants