Commit 6c76d798 authored by Radford Neal's avatar Radford Neal

changes to error handling for replacement, implemented in length<- and environment<-

parent fdbe4bb5
......@@ -3,3 +3,8 @@ Modifications to do_set and applydefine for complex assignments.
Also, added a codePromises option for deparse, and NA option for
evaluate in dump, which goes with these being needed for better
error display in the new scheme.
Make deparsing for errors use the new codePromises option, and
change length<- and environment<- to use errorcall rather than
error so it will be used there. Need to do the same for other
primitive replacement functions.
......@@ -299,7 +299,7 @@ static SEXP do_envirgets(SEXP call, SEXP op, SEXP args, SEXP rho)
if (!isNull(env) && !isEnvironment(env)
&& !isEnvironment(env = simple_as_environment(env)))
error(_("replacement object is not an environment"));
errorcall(call,_("replacement object is not an environment"));
PROTECT(env);
......@@ -310,7 +310,7 @@ static SEXP do_envirgets(SEXP call, SEXP op, SEXP args, SEXP rho)
if (TYPEOF(CAR(args)) == CLOSXP) {
if (isNull(env))
error(_("use of NULL environment is defunct"));
errorcall(call,_("use of NULL environment is defunct"));
if (TYPEOF(BODY(s)) == BCODESXP)
/* switch to interpreted version if compiled */
SET_BODY(s, R_ClosureExpr(CAR(args)));
......@@ -841,13 +841,13 @@ static SEXP do_lengthgets(SEXP call, SEXP op, SEXP args, SEXP rho)
rho, &ans, 0, 1))
return(ans);
if (!isVector(x) && !isVectorizable(x))
error(_("invalid argument"));
errorcall(call,_("invalid argument"));
if (length(CADR(args)) != 1)
error(_("invalid value"));
errorcall(call,_("invalid value"));
len = asVecSize(CADR(args));
if (len == NA_INTEGER)
error(_("missing value for 'length'"));
if (len < 0) error(_("invalid value"));
errorcall(call,_("missing value for 'length'"));
if (len < 0) errorcall(call,_("invalid value"));
return lengthgets(x, len);
}
......
......@@ -297,7 +297,7 @@ SEXP attribute_hidden deparse1s(SEXP call)
Rboolean backtick=TRUE;
temp = deparse1WithCutoff(call, FALSE, DEFAULT_Cutoff, backtick,
DEFAULTDEPARSE, 1);
DEFAULTDEPARSE | CODEPROMISES, 1);
return(temp);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment