mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Error on defining disc for undeclared type member (re: 87088361
)
$ typeset -T _bad_disc_t=(typeset dummy; function foo.get { :; }) Abort One of the abort() calls that replaced a debug message in the referenced commit was triggered when trying to define a discipline function for a nonexistent type member inside a 'typeset -T' type definition. src/cmd/ksh93/sh/nvtype.c: std_disc(): - Issue a proper error message for that condition.
This commit is contained in:
parent
2a43cbc3f6
commit
7b8e7fbb49
2 changed files with 13 additions and 1 deletions
|
@ -757,7 +757,12 @@ found:
|
|||
}
|
||||
}
|
||||
nv_onattr(mp,NV_NOFREE);
|
||||
if(!np || !nv_setdisc(np, cp, mp, (Namfun_t*)np))
|
||||
if(!np)
|
||||
{
|
||||
errormsg(SH_DICT,ERROR_exit(1),"%s: cannot set discipline for undeclared type member",sp);
|
||||
UNREACHABLE();
|
||||
}
|
||||
if(!nv_setdisc(np, cp, mp, (Namfun_t*)np))
|
||||
abort();
|
||||
return(1);
|
||||
}
|
||||
|
|
|
@ -771,5 +771,12 @@ namespace sh.type
|
|||
[[ $got == "$exp" ]] || err_exit "'tyeset -p .sh.type' failed" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# Check for correct error message when attempting to set a discipline function for a nonexistent type member
|
||||
exp=": foo.get: cannot set discipline for undeclared type member"
|
||||
got=$(set +x; redirect 2>&1; typeset -T _bad_disc_t=(typeset dummy; function foo.get { :; }); echo end_reached)
|
||||
let "(e=$?)==1" && [[ $got == *"$exp" ]] || err_exit "attempt to set disc for nonexistent type member not handled correctly" \
|
||||
"(expected status 1, match of *$(printf %q "$exp"); got status $e, $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue