summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--compile.c2
-rw-r--r--parse.y7
3 files changed, 12 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b7c7d1d6f..660e1ab67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun May 17 14:23:08 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * compile.c (rb_parse_in_eval): returns true in true eval, not in
+ main. [ruby-dev:38382]
+
+ * parse.y (program): inherits dvars in eval or main.
+
Sun May 17 14:02:56 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (ruby_script): sets also VM toplevel program name.
diff --git a/compile.c b/compile.c
index 3ddd06129..fc5ed90a0 100644
--- a/compile.c
+++ b/compile.c
@@ -5416,7 +5416,7 @@ rb_local_defined(ID id)
int
rb_parse_in_eval(void)
{
- return GET_THREAD()->parse_in_eval != 0;
+ return GET_THREAD()->parse_in_eval > 0;
}
int
diff --git a/parse.y b/parse.y
index 7c11b7b2f..884814504 100644
--- a/parse.y
+++ b/parse.y
@@ -760,14 +760,15 @@ static void token_info_pop(struct parser_params*, const char *token);
program : {
lex_state = EXPR_BEG;
/*%%%*/
- local_push(compile_for_eval);
+ $<num>$ = compile_for_eval || rb_parse_in_main();
+ local_push($<num>$);
/*%
%*/
}
compstmt
{
/*%%%*/
- if ($2 && !compile_for_eval) {
+ if ($2 && !$<num>1) {
/* last expression should not be void */
if (nd_type($2) != NODE_BLOCK) void_expr($2);
else {
@@ -4993,7 +4994,7 @@ yycompile0(VALUE arg, int tracing)
NODE *tree;
struct parser_params *parser = (struct parser_params *)arg;
- if ((!compile_for_eval || rb_parse_in_main()) && rb_safe_level() == 0) {
+ if (!compile_for_eval && rb_safe_level() == 0) {
ruby_debug_lines = debug_lines(ruby_sourcefile);
if (ruby_debug_lines && ruby_sourceline > 0) {
VALUE str = STR_NEW0();