fixed a bug of not checking a function name against named variables
This commit is contained in:
parent
b9d3b490a2
commit
3c63104bf7
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c 215 2009-06-27 05:52:54Z hyunghwan.chung $
|
||||
* $Id: parse.c 216 2009-06-27 12:42:53Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -845,7 +845,8 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
if (qse_map_search (awk->tree.funs, name, name_len) != QSE_NULL)
|
||||
/* check if it has already been defined as a function */
|
||||
if (qse_map_search (awk->tree.funs, name, name_len) != QSE_NULL)
|
||||
{
|
||||
/* the function is defined previously */
|
||||
SETERRARG (
|
||||
@ -854,6 +855,15 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* check if it conflicts with a named variable */
|
||||
if (qse_map_search (awk->parse.named, name, name_len) != QSE_NULL)
|
||||
{
|
||||
SETERRARG (
|
||||
awk, QSE_AWK_EVARRED, awk->token.line,
|
||||
name, name_len);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* check if it coincides to be a global variable name */
|
||||
g = find_global (awk, name, name_len);
|
||||
if (g != QSE_LDA_NIL)
|
||||
|
@ -1,6 +1,6 @@
|
||||
function f(f)
|
||||
function f(x)
|
||||
{
|
||||
print f;
|
||||
print x;
|
||||
f("my hello");
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
# should print 50
|
||||
function fn(f) { f = 20; }
|
||||
BEGIN { f = 50; fn(100); print f; }
|
||||
# should print 50
|
||||
function fn(f) { f = 20; }
|
||||
BEGIN { f = 50; fn(100); print f; }
|
||||
|
@ -1,3 +1,3 @@
|
||||
# A function and a named variable cannot have the same name.
|
||||
function a () { }
|
||||
BEGIN { a = 20; }
|
||||
function a () { }
|
||||
BEGIN { a = 20; }
|
||||
|
Loading…
Reference in New Issue
Block a user