class ValidFailInst < Kaitai::Struct::Struct
# ...
def e
return @e unless @e.nil?
_pos = @_io.pos
@_io.seek(0)
@e = @_io.read_bytes(1)
@_io.seek(_pos)
raise Kaitai::Struct::ValidationNotEqualError.new([200].pack('C*'), e, _io, "/instances/e") if not e == [200].pack('C*')
@e
end
So it looks like we've forgotten about this case (and of course there is no test for it in our test suite). In fact, it's even a 0.9 regression (that's right, another regression related to contents), because contents in a parse instance used to work in 0.8:
class ContentsFailInst < Kaitai::Struct::Struct
# ...
def e
return @e unless @e.nil?
_pos = @_io.pos
@_io.seek(0)
@e = @_io.ensure_fixed_contents([200].pack('C*'))
@_io.seek(_pos)
@e
end
Since 0.9, KSC doesn't generate any validation for a positional instance which uses the
contents
key:In this case, the generated code only reads one byte in
e
:But when
valid
is used, the validation works:So it looks like we've forgotten about this case (and of course there is no test for it in our test suite). In fact, it's even a 0.9 regression (that's right, another regression related to
contents
), becausecontents
in a parse instance used to work in 0.8: