Skip to content

Rust: invalid codegen for groups with fields of type with 'sinceVersion' #984

New issue

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

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

Already on GitHub? # to your account

Closed
mward opened this issue Apr 5, 2024 · 2 comments
Closed

Comments

@mward
Copy link
Contributor

mward commented Apr 5, 2024

This is similar to #972 but specific to simple type with sinceVersion > 0

<sbe:messageSchema
    xmlns:sbe="http://fixprotocol.io/2016/sbe"
    package="example"
    id="123"
    version="3"
    semanticVersion="5.0.0"
    byteOrder="littleEndian">
  <types>
    <type name="String4" length="4" primitiveType="char" semanticType="String"/>
    <type name="String5" length="5" primitiveType="char" sinceVersion="2" semanticType="String"/>
    <type name="String6" length="6" primitiveType="char" sinceVersion="3" semanticType="String"/>
    <composite name="groupSize" description="Repeating group dimensions" semanticType="NumInGroup">
      <type name="blockLength" primitiveType="uint16"/>
      <type name="numInGroup" primitiveType="uint8"/>
    </composite>
    <composite name="messageHeader">
      <type name="blockLength" primitiveType="uint16"/>
      <type name="templateId" primitiveType="uint16" description="Template ID used to encode the message."/>
      <type name="schemaId" primitiveType="uint16" description="ID of the system publishing the message."/>
      <type name="version" primitiveType="uint16" description="Schema version."/>
    </composite>
  </types>
  <sbe:message name="SimpleMessage" id="1">
    <field name="id" id="2" type="uint16" semanticType="Int"/>
    <group name="MyGroup" id="3" blockLength="15" dimensionType="groupSize">
      <field name="f1" id="4" type="String4" offset="0" semanticType="String"/>
      <field name="f2" id="5" type="String5" offset="4" semanticType="String"/>
      <field name="f3" id="6" type="String6" offset="9" semanticType="String"/>
    </group>
  </sbe:message>
</sbe:messageSchema>

rust compiler complains with:

error[E0609]: no field `acting_version` on type `&simple_message_codec::decoder::MyGroupDecoder<P>`
   --> src/simple_message_codec.rs:382:21
    |
382 |             if self.acting_version > 0 && self.acting_version < 2 {
    |                     ^^^^^^^^^^^^^^ unknown field
    |
    = note: available fields are: `parent`, `block_length`, `count`, `index`, `offset`

I have a fix that will resolve this, will submit pull request

@mward
Copy link
Contributor Author

mward commented Apr 5, 2024

Submitted pull request: #985

vyazelenko pushed a commit that referenced this issue Apr 5, 2024
* [Rust] updated code generator to prevent rust warning for "ambiguous glob re-exports"

* [Rust] defined new trait 'ActingVersion'

* fixed code formatting issues

* [Rust] fixed benchmarks

* [Rust] added test for issue 984

---------

Co-authored-by: Michael Ward <mward@drw.com>
@vyazelenko
Copy link
Contributor

PR merged.

DarrylGamroth pushed a commit to New-Earth-Lab/simple-binary-encoding that referenced this issue Nov 19, 2024
…#985)

* [Rust] updated code generator to prevent rust warning for "ambiguous glob re-exports"

* [Rust] defined new trait 'ActingVersion'

* fixed code formatting issues

* [Rust] fixed benchmarks

* [Rust] added test for issue 984

---------

Co-authored-by: Michael Ward <mward@drw.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants