Skip to content

bug on simple parsing? #18

@pietroppeter

Description

@pietroppeter

ran into it while trying this library for today's aoc:

import binaryparse, streams

block:
  let test1 = newStringStream("\xD2\xFE\x28")

  createParser(packet):
    u3: version
    u3: typeId
  
  var data = packet.get(test1)
  dump data

outputs:

data = (version: 6, typeId: 7)

but typeId should be 4.

For comparison binarylang has the correct output:

import binarylang

block:
  let test1 = newStringBitStream("\xD2\xFE\x28")

  struct(packet):
    u3: version
    u3: typeId

  var data = packet.get(test1)
  # data is an object without a $ proc defined
  echo data.version
  echo data.typeId

outputs:

6
4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions