[前][次][番号順一覧][スレッド一覧][生データ]

yarv-dev:817

From: sheepman <sheepman sheepman.sakura.ne.jp>
Date: Tue, 7 Feb 2006 23:47:12 +0900
Subject: [yarv-dev:817] open> defining constants in BEGIN causes an error

こんばんは、sheepman です。
BEGIN の中で定数を定義するとエラーになります。

$ cat t.rb
BEGIN{
  A = 1
  p A
}

$ ./miniruby -v t.rb
ruby 1.9.0 (2005-11-18) [i686-linux]
YARVCore 0.3.3 (rev: 369) [opts: ]
DBG> : ":0:in `initialize'"
-- stack frame ------------
0x402b1008 (0000): 00000001
0x402b100c (0001): 00000001 <- lfp <- dfp
-- control frame ----------
c:0003 p:-001 s:0002 b:0002 l:0001 d:0001 CFUNC  i:initialize s:         -
c:0002 p:-001 s:0001 b:0001 l:0000 d:0000 CFUNC  i:initialize s:         -
c:0001 p:-001 s:0000 b:-001 l:0000 d:0000 ------ i:-        s:         -
---------------------------
[BUG] must be class or block
ruby 1.9.0 (2005-11-18) [i686-linux]

zsh: abort (core dumped)  ./miniruby -v t.rb

以下はバックトレースです。

(gdb) bt
#0  0x400ecc11 in kill () from /lib/i686/libc.so.6
#1  0x4002a341 in pthread_kill () from /lib/i686/libpthread.so.0
#2  0x4002a6bb in raise () from /lib/i686/libpthread.so.0
#3  0x400ec8a4 in raise () from /lib/i686/libc.so.6
#4  0x400ee008 in abort () from /lib/i686/libc.so.6
#5  0x080c9336 in rb_bug (fmt=0x80f6871 "must be class or block") at ../yarv/error.c:173
#6  0x080d079c in iseq_compile (self=1076460312, narg=1076460252) at ../yarv/compile.c:250
#7  0x080b954c in iseq_init (self=1076460052, node=1076460252, name=1076460072,
    file_name=1076460212, parent=0, type=3, opt=0) at ../yarv/yarvcore.c:514
#8  0x080b7fca in call_cfunc (func=0x80b9510 <iseq_init>, recv=1076460052, len=1073937284,
    argc=6, argv=0x6) at call_cfunc.h:39
#9  0x080b35d5 in th_call0 (th=0x813e288, klass=0, recv=1076460052, id=0, oid=0, argc=6,
    argv=0xbfffe5d0, body=0x40298f04, nosuper=0) at ../yarv/vm.c:420
#10 0x0805a3c7 in rb_call (klass=1076465552, recv=1076460052, mid=3001, argc=6, argv=0xbfffe5d0,
    scope=1) at yarv.h:49
#11 0x0805a6b5 in rb_funcall2 (recv=0, mid=3001, argc=6, argv=0xbfffe5d0) at ruby.h:667
#12 0x0805b8de in rb_obj_call_init (obj=1076460052, argc=6, argv=0xbfffe5d0)
    at ../yarv/eval.c:2510
#13 0x08073acc in rb_class_new_instance (argc=6, argv=0xbfffe5d0, klass=1076465552)
    at ../yarv/object.c:1455
#14 0x080d0d56 in new_child_iseq (iseq=0x8141e18, node=0x0, name=0, parent=0, type=0, opt=0)
    at ../yarv/compile.c:724
#15 0x080d803f in iseq_compile_each (iseq=0x8141e18, ret=0xbfffe880, node=0x40297ac8, poped=0)
    at ../yarv/compile.c:4253
#16 0x080d07bb in iseq_compile (self=1076460172, narg=1076460232) at ../yarv/compile.c:241
#17 0x080b954c in iseq_init (self=1076460172, node=1076460232, name=1076460192,
    file_name=1076460212, parent=0, type=3, opt=0) at ../yarv/yarvcore.c:514
#18 0x080b7fca in call_cfunc (func=0x80b9510 <iseq_init>, recv=1076460172, len=1073937284,
    argc=6, argv=0x6) at call_cfunc.h:39
#19 0x080b35d5 in th_call0 (th=0x813e288, klass=0, recv=1076460172, id=0, oid=0, argc=6,
    argv=0xbfffea70, body=0x40298f04, nosuper=0) at ../yarv/vm.c:420
#20 0x0805a3c7 in rb_call (klass=1076465552, recv=1076460172, mid=3001, argc=6, argv=0xbfffea70,
    scope=1) at yarv.h:49
#21 0x0805a6b5 in rb_funcall2 (recv=0, mid=3001, argc=6, argv=0xbfffea70) at ruby.h:667
#22 0x0805b8de in rb_obj_call_init (obj=1076460172, argc=6, argv=0xbfffea70)
    at ../yarv/eval.c:2510
#23 0x08073acc in rb_class_new_instance (argc=6, argv=0xbfffea70, klass=1076465552)
    at ../yarv/object.c:1455
#24 0x080b9083 in yarv_new_iseqval (node=0, name=0, file=0, parent=0, type=0, opt=0)
    at ../yarv/yarvcore.c:345
#25 0x080b8f6f in th_compile_from_node (th=0x0, node=0x40297ac8, file=6) at ../yarv/yarvcore.c:286
#26 0x080b8fd7 in yarvcore_eval_parsed (node=1076460232, file=1076460212) at yarv.h:49
#27 0x080587bc in ruby_exec_internal () at ../yarv/eval.c:262
#28 0x080587f0 in ruby_exec () at ../yarv/eval.c:274
#29 0x0805882b in ruby_run () at ../yarv/eval.c:291
#30 0x08055f4d in main () at ../yarv/main.c:36
#31 0x400d9c1f in __libc_start_main () from /lib/i686/libc.so.6

-- 
sheepman / TAMURA Takashi
sheepman sheepman.sakura.ne.jp http://sheepman.parfait.ne.jp/

-- 
ML: yarv-dev quickml.atdot.net
使い方: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]

->     817 2006-02-07 23:47 [sheepman sheepman.sa] open> defining constants in BEGIN causes an error
       867 2006-02-14 06:25 ┗[ko1 atdot.net       ]                                       
       868 2006-02-14 06:26  ┣[ko1 atdot.net       ] fixed> Re: open> defining constants in BEGIN causes an error
       871 2006-02-14 09:15  ┣[matz ruby-lang.org  ]                                     
       886 2006-02-14 19:08  ┗[sheepman sheepman.sa] close> defining constants in BEGIN causes an error