[#18440] racc segv revisited — "Akinori MUSHA" <knu@...>

 次のバグの件なんですが、現時点では原因究明を含めて未解決という

24 messages 2002/10/02
[#18617] Re: racc segv revisited — "Akinori MUSHA" <knu@...> 2002/11/02

At Wed, 2 Oct 2002 23:19:59 +0900,

[ruby-dev:18547] Re: symbol literal with non-alphanumeric

From: nobu.nakada@...
Date: 2002-10-21 12:56:20 UTC
List: ruby-dev #18547
なかだです。

At Mon, 21 Oct 2002 14:14:46 +0900,
Yukihiro Matsumoto wrote:
> しばらく頭を冷やしたら以下の点を明確にする必要がある気がして
> きました。
> 
>   * :".."形式で式展開を許すか(許したほうが一貫性がある?)

やっぱり使えたほうがいいでしょうか。NODEを追加したほうがいいの
かも知れませんが、とりあえず[ruby-dev:18537]への追加です。

>   * 現在internする文字列は\0を含むことができないことをどうす
>     るか

うーん、これはそのままエラーでいいような気がするんですが。


--- parse.y~	Fri Oct 18 23:14:17 2002
+++ parse.y	Mon Oct 21 21:41:34 2002
@@ -239,5 +239,5 @@ static void top_local_setup();
 %type <node> string_contents xstring_contents string_content
 %type <node> words qwords word_list qword_list word
-%type <node> literal numeric
+%type <node> literal numeric dsym
 %type <node> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
 %type <node> expr_value arg_value primary_value
@@ -1741,4 +1741,5 @@ literal		: numeric
 			$$ = NEW_LIT(ID2SYM($1));
 		    }
+		| dsym
 		;
 
@@ -1956,12 +1957,19 @@ sym		: fname
 		| tGVAR
 		| tCVAR
-		| tSTRING_CONTENT tSTRING_END
-		    {
-			$$ = rb_intern(RSTRING($1->nd_lit)->ptr);
-			rb_gc_force_recycle((VALUE)$1);
-		    }
-		| tSTRING_END
+		;
+
+dsym		: tSYMBEG xstring_contents tSTRING_END
 		    {
-			yyerror("empty symbol literal");
+		        lex_state = EXPR_END;
+			if (!$2) {
+			    yyerror("empty symbol literal");
+			}
+			else if (nd_type($2) == NODE_STR) {
+			    $2->nd_lit = ID2SYM(rb_intern(RSTRING($2->nd_lit)->ptr));
+			    $$ = $2;
+			}
+			else {
+			    $$ = NEW_CALL($2, rb_intern("intern"), 0);
+			}
 		    }
 		;


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread