[Bug] yue.require does not propagate errors to Lua

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
lua
領域
tooling

調査の方向性

まず、示されている LuaJIT の例で、yue.require("temp") と提供された temp.yue のエラーケースを使って問題を再現します。yue.require のエントリポイントを追跡し、なぜエラーが握りつぶされ、なぜ traceback が出力されるのかを特定します。pcall が失敗を受け取り、カスタム xpcall ハンドラを実行でき、yue.require が traceback を自動的に出力しなくなれば完了です。

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

説明

The YueScript documentation says to use yue.require() to perform custom error handling:

local yue = require("yue")
local success, result = xpcall(function()
    yue.require("yuescript_module_name")
end, function(err)
    return yue.traceback(err)
end)

However, this does not work. When throwing an error in a .yue file, the call to yue.require() will not fail and just return nothing. The error handler defined here will not be called, either. Furthermore, yue.require() always prints a traceback with yue.traceback().

Image

The screenshot shows a file called temp.yue that contains the following code:





const f = () ->
	error("Test message")



f()



It is being executed with LuaJIT, with the following code:

yue = require("yue")
print(pcall(yue.require, "temp"))

The output is:

Test message
Stack Traceback
===============
(1) '=(yuescript)':172
(2) global C function 'pcall'
(3) '=stdin':1
(4)  C function 'function: 0x7e8c2865c588'

true nil
主要言語
Lua
スター
620
フォーク
45
平均マージ
9時間 5分
マージ済み PR(30日)
1

環境構築

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

はじめの一歩

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

IppClub/YueScript のほかの issue

IppClub/YueScript の issue をすべて見る

似ている issue

Lua の issue をもっと見る

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

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