Skip to content

Commit afebe66

Browse files
committed
fix: forbid redefinition of particles
1 parent aca9b69 commit afebe66

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

check/fixes.frm

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,6 +3864,74 @@ assert succeeded?
38643864
assert result("test1") =~ expr("f(i1,N1_?,N2_?,i4)^2")
38653865
assert result("test2") =~ expr("f(N1_?,N2_?,N3_?,N4_?)^2")
38663866
*--#] Issue615 :
3867+
*--#[ Issue617_1 :
3868+
#-
3869+
Model TMP;
3870+
Particle s;
3871+
Particle i;
3872+
Particle v;
3873+
Particle cf;
3874+
Particle f;
3875+
Particle ct;
3876+
Particle t;
3877+
Particle ctab;
3878+
Particle tab;
3879+
EndModel;
3880+
Symbol s;
3881+
Index i;
3882+
Vector v;
3883+
CFunction cf;
3884+
Function f;
3885+
CTensor ct;
3886+
Tensor t;
3887+
CTable ctab(1:2,3:4);
3888+
NTable tab(1:2,3:4);
3889+
.end
3890+
assert runtime_error?("s has been declared as a function already")
3891+
assert runtime_error?("v has been declared as a function already")
3892+
assert runtime_error?("i has been declared as a function already")
3893+
assert runtime_error?("Function or Tensor cf already declared as a Particle")
3894+
assert runtime_error?("Function or Tensor f already declared as a Particle")
3895+
assert runtime_error?("Function or Tensor ct already declared as a Particle")
3896+
assert runtime_error?("Function or Tensor t already declared as a Particle")
3897+
assert runtime_error?("(N)(C)Tables should not be declared previously")
3898+
*--#] Issue617_1 :
3899+
*--#[ Issue617_2 :
3900+
#-
3901+
Symbol s;
3902+
Index i;
3903+
Vector v;
3904+
CFunction cf;
3905+
Function f;
3906+
CTensor ct;
3907+
Tensor t;
3908+
CTable ctab(1:2,3:4);
3909+
NTable tab(1:2,3:4);
3910+
Model TMP;
3911+
Particle s;
3912+
Particle i;
3913+
Particle v;
3914+
Particle cf;
3915+
Particle f;
3916+
Particle ct;
3917+
Particle t;
3918+
Particle ctab;
3919+
Particle tab;
3920+
EndModel;
3921+
.end
3922+
assert runtime_error?("s has been declared as a symbol already")
3923+
assert runtime_error?("Name of particle previously declared as another variable: s")
3924+
assert runtime_error?("i has been declared as an index already")
3925+
assert runtime_error?("Name of particle previously declared as another variable: i")
3926+
assert runtime_error?("v has been declared as a vector already")
3927+
assert runtime_error?("Name of particle previously declared as another variable: v")
3928+
assert runtime_error?("Name of particle previously declared as another variable: cf")
3929+
assert runtime_error?("Name of particle previously declared as another variable: f")
3930+
assert runtime_error?("Name of particle previously declared as another variable: ct")
3931+
assert runtime_error?("Name of particle previously declared as another variable: t")
3932+
assert runtime_error?("Name of particle previously declared as another variable: ctab")
3933+
assert runtime_error?("Name of particle previously declared as another variable: tab")
3934+
*--#] Issue617_2 :
38673935
*--#[ Issue631_1 :
38683936
#procedure foo(?a)
38693937
#message `toupper_(abc)'

sources/names.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,10 @@ retry:;
16031603
MesPrint("&Tensor %s changed to function",name);
16041604
error = 1;
16051605
}
1606+
else if ( fun->spec == VERTEXFUNCTION ) {
1607+
MesPrint("&Function or Tensor %s already declared as a Particle",name);
1608+
error = 1;
1609+
}
16061610
fun->spec = istensor;
16071611
if ( fun->symmetric != symtype ) {
16081612
fun->symmetric = symtype;

0 commit comments

Comments
 (0)