From: DeaDDooMER Date: Wed, 27 Sep 2017 17:28:08 +0000 (+0300) Subject: Исправен конфликт имён локальных и глобальных процедур X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=dd188cb697c08d52aefb144a4f3a943dbf3388c5;p=dsw-obn.git Исправен конфликт имён локальных и глобальных процедур --- diff --git a/Test.obn b/Test.obn index 6fae529..da60894 100644 --- a/Test.obn +++ b/Test.obn @@ -1,3 +1,11 @@ MODULE Test; +PROCEDURE A; +END A; + +PROCEDURE B; + PROCEDURE A; + END A; +END B; + END Test. diff --git a/obn-run-tests.sh b/obn-run-tests.sh index 8db6f37..2ce7572 100755 --- a/obn-run-tests.sh +++ b/obn-run-tests.sh @@ -101,3 +101,4 @@ maketest Test25 maketest Test26 maketest Test27 maketest Test28 +maketest Test29 diff --git a/src/oberon.c b/src/oberon.c index cd7e97a..8256647 100644 --- a/src/oberon.c +++ b/src/oberon.c @@ -305,6 +305,21 @@ oberon_find_object(oberon_scope_t * scope, char * name, bool check_it) return result; } +static oberon_object_t * +oberon_find_object_in_scope(oberon_scope_t * scope, char * name, bool check_it) +{ + oberon_object_t * result = NULL; + + result = oberon_find_object_in_list(scope -> list, name); + + if(check_it && result == NULL) + { + oberon_error(scope -> ctx, "undefined ident %s", name); + } + + return result; +} + static oberon_object_t * oberon_create_object(oberon_scope_t * scope, char * name, int class, bool export, bool read_only) { @@ -2469,7 +2484,7 @@ oberon_proc_decl(oberon_context_t * ctx) oberon_close_scope(ctx -> decl); oberon_object_t * proc; - proc = oberon_find_object(ctx -> decl, name, 0); + proc = oberon_find_object_in_scope(ctx -> decl, name, 0); if(proc == NULL) { proc = oberon_define_object(ctx -> decl, name, OBERON_CLASS_PROC, export, read_only, false); diff --git a/tests/Test29.obn b/tests/Test29.obn new file mode 100644 index 0000000..ab7e493 --- /dev/null +++ b/tests/Test29.obn @@ -0,0 +1,13 @@ +MODULE Test29; + +PROCEDURE A; +END A; + +PROCEDURE B; + PROCEDURE A; + END A; +END B; + +END Test29. + +Объявление локальной процедуры не должно конфликтовать с глобальным.