`unused variable` warning is reported when grammer definition includes `*` qualifier
評価
調査の方向性
* 修飾子と生成された test.tab.rb を使う文法から始め、特にレポートに示されている _reduce_1 メソッドと _reduce_2 メソッドを確認します。racc test.y に続けて ruby -W test.tab.rb を実行して警告を再現し、修飾子ありと修飾子なしで生成された還元を比較します。再現した文法で未使用の result に関する警告が報告されなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Ruby reports unused variable warning for source file generated from the grammar definition includes * qualifier.
How to reproduce:
Give the source file geneated from the grammer definition below to Ruby with -W option.
class TestParser
options no_result_var
rule
root
: 'a' 'b'*
$ racc --version
racc version 1.8.1
$ racc test.y
$ ruby -W test.tab.rb
test.y:8: warning: assigned but unused variable - result
test.y:8: warning: assigned but unused variable - result
Ruby code below is geneated from the the above grammer definition.
#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.8.1
# from Racc grammar file "test.y".
#
require 'racc/parser.rb'
class TestParser < Racc::Parser
##### State transition tables begin ###
racc_action_table = [
2, 3, 4, 6, 4 ]
racc_action_check = [
0, 1, 2, 3, 4 ]
racc_action_pointer = [
-2, 1, -1, 3, 1, nil, nil, nil ]
racc_action_default = [
-4, -4, -1, -4, -1, -3, 8, -2 ]
racc_goto_table = [
5, 1, 7 ]
racc_goto_check = [
2, 1, 2 ]
racc_goto_pointer = [
nil, 1, -2 ]
racc_goto_default = [
nil, nil, nil ]
racc_reduce_table = [
0, 0, :racc_error,
0, 6, :_reduce_1,
2, 6, :_reduce_2,
2, 5, :_reduce_none ]
racc_reduce_n = 4
racc_shift_n = 8
racc_token_table = {
false => 0,
:error => 1,
"a" => 2,
"b" => 3 }
racc_nt_base = 4
racc_use_result_var = false
Racc_arg = [
racc_action_table,
racc_action_check,
racc_action_default,
racc_action_pointer,
racc_goto_table,
racc_goto_check,
racc_goto_default,
racc_goto_pointer,
racc_nt_base,
racc_reduce_table,
racc_token_table,
racc_shift_n,
racc_reduce_n,
racc_use_result_var ]
Ractor.make_shareable(Racc_arg) if defined?(Ractor)
Racc_token_to_s_table = [
"$end",
"error",
"\"a\"",
"\"b\"",
"$start",
"root",
"\"-many@b\"" ]
Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
Racc_debug_parser = false
##### State transition tables end #####
# reduce 0 omitted
module_eval(<<'.,.,', 'test.y', 7)
def _reduce_1(val, _values)
result = val[1] ? val[1].unshift(val[0]) : val
end
.,.,
module_eval(<<'.,.,', 'test.y', 7)
def _reduce_2(val, _values)
result = val[1] ? val[1].unshift(val[0]) : val
end
.,.,
# reduce 3 omitted
def _reduce_none(val, _values)
val[0]
end
end # class TestParser
- 主要言語
- Yacc
- スター
- 569
- フォーク
- 94
- 平均マージ
- 12時間 11分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/racc のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
似ている issue
-
VX_PRINT_DROPS prints each drop point twice on the default code generator, the second time at line 0オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Bisect issue229646オープンbisect
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dtcxzyw/llvm-bisect-service#418 · コメント 1 件 ·
-
area:prove bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Chelis-Lang/chelis#3317 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/TypeScript#64661 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100