From 867bab03023fa81f09d53e6ba7a1f0d87340aeaf Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Thu, 29 Oct 2026 16:32:19 +0100 Subject: [PATCH] Reject non-public interface methods at compile time --- engine/compiler.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/compiler.c b/engine/compiler.c index 79a1359..16fc02f 100644 --- a/engine/compiler.c +++ b/engine/compiler.c @@ -3904,8 +3904,10 @@ static sxi32 PH7_CompileClassInterface(ph7_gen_state *pGen) { /* Extract the current keyword */ nKwrd = SX_PTR_TO_INT(pGen->pIn->pUserData); if(nKwrd == PH7_KEYWORD_PRIVATE || nKwrd == PH7_KEYWORD_PROTECTED) { - /* Emit a warning and switch to public visibility */ - PH7_GenCompileError(&(*pGen), E_WARNING, pGen->pIn->nLine, "interface: Access type must be public"); + /* Preserve constant visibility recovery; non-public methods are fatal. */ + PH7_GenCompileError(&(*pGen), + pGen->pIn + 1 < pGen->pEnd && SX_PTR_TO_INT(pGen->pIn[1].pUserData) == PH7_KEYWORD_CONST ? E_WARNING : E_ERROR, + pGen->pIn->nLine, "interface: Access type must be public"); nKwrd = PH7_KEYWORD_PUBLIC; } if(nKwrd == PH7_KEYWORD_PUBLIC) {