messagepack.decode example uses an undefined bytes variable

オープン 初心者向け
#2 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
lua
領域
documentation

調査の方向性

messagepack/api/messagepack.script_api にある messagepack.decode の3つ目の例を読み、バイト列 d4 00 00 を使うデコードテストと比較してください。不足しているバイト列の定義と提案されたアサーションを追加し、Script API のチェックと該当するデコードテストを実行してください。定義済みの入力で例が実行され、デコードされた値を検証できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

The third example for messagepack.decode in messagepack/api/messagepack.script_api passes bytes to decode, but never defines it. Copied as is, decode gets nil and fails with an argument error.

This is the example right now:

-- msgpackr (JavaScript) writes undefined as extension type 0
local UNDEFINED = setmetatable({}, {
    __tostring = function() return "undefined" end
})
local options = {ext = {[0] = function() return UNDEFINED end}}
local value = messagepack.decode(bytes, options)

The decode tests already use the bytes msgpackr writes for undefined (d4 00 00, fixext 1 with type 0), so the example could build them the same way. Something like this:

-- msgpackr (JavaScript) writes undefined as extension type 0
local bytes = string.char(0xd4, 0x00, 0x00)
local UNDEFINED = setmetatable({}, {
    __tostring = function() return "undefined" end
})
local options = {ext = {[0] = function() return UNDEFINED end}}
local value = messagepack.decode(bytes, options)
assert(value == UNDEFINED)

The only changes are the local bytes line and the assert at the end.

The script API test only loads each example with --check-lua, so it passes even though the snippet can't run on its own.

主要言語
C++
スター
6
フォーク
1
平均マージ
13日 6時間
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。