From a752292b54e22a8024b9d9162762edd2efa533b5 Mon Sep 17 00:00:00 2001 From: zinc Date: Wed, 14 Oct 2026 16:10:42 +0330 Subject: fndef: a second definition of a function in the same module is 'is defined twice' (appendix b.2.3) --- src/compiler/decl.zc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/compiler/decl.zc b/src/compiler/decl.zc index 0870756..6794373 100644 --- a/src/compiler/decl.zc +++ b/src/compiler/decl.zc @@ -285,6 +285,10 @@ int fndef(int chk, int rty, int ret, int n) { if (rty || ntp) typed = 1; if (!dnm) dnm = n; s = lookup(n); + if (s >= ubase && skind[s] == K_FN && (sflag[s] & F_DEF) && !(sflag[s] & F_TPL) && !ginst && !ntp) { // appendix b.2.3: the same name in the same module + word qn = n; if (module_name) qn = module_symbol(n); + if (rt.eq_w(sname[s], qn)) serrn(n, "is defined twice"); + } if (s < 0 || s < ubase || skind[s] != K_FN || (sflag[s] & F_DEF)) { s = addsym(n, K_FN, 0); sflag[s] = 0; -- cgit v1.2.3