From 788fb4f93faff1b30cfecfe3fad3cffb08552951 Mon Sep 17 00:00:00 2001 From: Takahiro Ueda Date: Fri, 23 Jan 2026 21:40:29 +0900 Subject: [PATCH] feat: warn about conflicting module options for $-variables A warning is emitted when module options conflict. Also, warnings for undefined $-variables now include the variable name. --- check/features.frm | 17 +++++++++++++++++ sources/module.c | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/check/features.frm b/check/features.frm index 97caa0cc..7c4dea5b 100644 --- a/check/features.frm +++ b/check/features.frm @@ -2357,6 +2357,23 @@ discard; .end assert succeeded? *--#] ModuleOption_dollar_order : +*--#[ ModuleOption_dollar_warnings_1 : +$a = 0; +ModuleOption local,$a; +ModuleOption local,$a; +.end +assert succeeded? +*--#] ModuleOption_dollar_warnings_1 : +*--#[ ModuleOption_dollar_warnings_2 : +ModuleOption local,$a; +$b = 0; +ModuleOption local,$b; +ModuleOption sum,$b; +.end +assert return_value == 0 +assert warning?("Undefined $-variable in module option; option ignored: $a") +assert warning?("Conflicting module options for $-variable; later option ignored: $b") +*--#] ModuleOption_dollar_warnings_2 : *--#[ Issue49 : * Add mul_ function for polynomial multiplications Symbols x,y,z; diff --git a/sources/module.c b/sources/module.c index 0486c930..86ec356d 100644 --- a/sources/module.c +++ b/sources/module.c @@ -659,6 +659,7 @@ UBYTE * DoModDollar(UBYTE *s, int type) UBYTE *name, c; WORD number; MODOPTDOLLAR *md; + int nummodopt; while ( *s == '$' ) { /* Read the name of the dollar @@ -671,8 +672,22 @@ UBYTE * DoModDollar(UBYTE *s, int type) c = *s; *s = 0; number = GetDollar(name); if ( number < 0 ) { + UBYTE *s1; number = AddDollar(s,0,0,0); - Warning("Undefined $-variable in module statement"); + s1 = strDup1((UBYTE *)"Undefined $-variable in module option; option ignored: $","Undefined $-variable in ModuleOption"); + s1 = AddToString(s1,name,0); + Warning((char *)s1); + M_free(s1,"Undefined $-variable in ModuleOption"); + } + for ( nummodopt = 0; nummodopt < NumModOptdollars; nummodopt++ ) { + if ( number == ModOptdollars[nummodopt].number && type != ModOptdollars[nummodopt].type ) { + UBYTE *s1; + s1 = strDup1((UBYTE *)"Conflicting module options for $-variable; later option ignored: $","Conflicting $-variable in ModuleOption"); + s1 = AddToString(s1,name,0); + Warning((char *)s1); + M_free(s1,"Conflicting $-variable in ModuleOption"); + break; + } } md = (MODOPTDOLLAR *)FromList(&AC.ModOptDolList); md->number = number;