diff --git a/src/bytecode/bytearray.hh b/src/bytecode/bytearray.hh index 96e8311..d1906ad 100644 --- a/src/bytecode/bytearray.hh +++ b/src/bytecode/bytearray.hh @@ -39,7 +39,7 @@ public: [[nodiscard]] size_t size() const { return data_.size(); } private: - std::vector data_; + std::vector data_ {}; }; class BytecodeParsingError : public std::runtime_error { diff --git a/src/bytecode/bytecodeprototype.hh b/src/bytecode/bytecodeprototype.hh index e292589..682986e 100644 --- a/src/bytecode/bytecodeprototype.hh +++ b/src/bytecode/bytecodeprototype.hh @@ -13,9 +13,11 @@ struct BytecodePrototype { using Value = std::variant; struct Function { - uint16_t n_pars = 0; - uint16_t n_locals = 0; - ByteArray code {}; + uint16_t n_pars; + uint16_t n_locals; + ByteArray code; + + Function(uint16_t n_pars_, uint16_t n_locals_) : n_pars(n_pars_), n_locals(n_locals_), code(ByteArray {}) {} }; std::vector constants {}; diff --git a/src/bytecode/tests.cc b/src/bytecode/tests.cc index c4aeb7f..d5cb4e9 100644 --- a/src/bytecode/tests.cc +++ b/src/bytecode/tests.cc @@ -83,8 +83,8 @@ TEST(Bytecode, Code) f.code.append_byte(0x68); f.code.append_int(42); - f = bp.functions.emplace_back(2, 1); - f.code.append_byte(0x42); + auto& f2 = bp.functions.emplace_back(2, 1); + f2.code.append_byte(0x42); std::vector expected = { // header