From dd188cb697c08d52aefb144a4f3a943dbf3388c5 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 27 Sep 2017 20:28:08 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B5=D0=BD?= =?utf8?q?=20=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA=D1=82=20=D0=B8?= =?utf8?q?=D0=BC=D1=91=D0=BD=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D1=8C=D0=BD?= =?utf8?q?=D1=8B=D1=85=20=D0=B8=20=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB?= =?utf8?q?=D1=8C=D0=BD=D1=8B=D1=85=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4?= =?utf8?q?=D1=83=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Test.obn | 8 ++++++++ obn-run-tests.sh | 1 + src/oberon.c | 17 ++++++++++++++++- tests/Test29.obn | 13 +++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/Test29.obn 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. + +Объявление локальной процедуры не должно конфликтовать с глобальным. -- 2.29.2