lib/minjs/func.rb in minjs-0.1.2 vs lib/minjs/func.rb in minjs-0.1.3
- old
+ new
@@ -15,17 +15,21 @@
lex.match_lit(ECMA262::PUNC_LPARENTHESIS) and
args = formal_parameter_list(lex, new_context) and
lex.match_lit(ECMA262::PUNC_RPARENTHESIS) and
lex.match_lit(ECMA262::PUNC_LCURLYBRAC) and
b=func_body(lex, new_context) and lex.match_lit(ECMA262::PUNC_RCURLYBRAC)
- f = ECMA262::StFunc.new(new_context, id, args, b, true)
+ f = ECMA262::StFunc.new(new_context, id, args, b, {:decl => true})
context.var_env.record.create_mutable_binding(id, nil)
context.var_env.record.set_mutable_binding(id, f, nil)
f
else
- nil
+ if b
+ raise ParseError.new("No `}' at end of function", lex)
+ else
+ raise ParseError.new("Bad function declaration", lex)
+ end
end
}
end
def func_exp(lex, context)
@@ -51,11 +55,14 @@
new_context.var_env.record.set_mutable_binding(id_opt, f, nil)
id_opt.context = new_context
end
f
else
- lex.debug_lit
- raise 'error'
+ if b
+ raise ParseError.new("No `}' at end of function", lex)
+ else
+ raise ParseError.new("Bad function declaration", lex)
+ end
end
}
end
def formal_parameter_list(lex, context)