Open Beliavsky opened 2 years ago
This will lead to ambiguity in cases like
character(80) fmt = "('do you mean this one?')"
fmt: format('or this one?')
write (6, fmt)
integer to, toto, tototo
to: continue
toto: continue
tototo: continue
assigntototototo
doiii=1,10
i: continue
ii: continue
integer label
assign 1 to label
go to label
1 print *, 'this one?'
return
label: print *, 'or this one?'
Can the ambiguity be avoided by requiring that the line label not have the same name as any variable or named constant in the program unit?
That would invalidate existing conformant code.
One could perhaps allow the same labels and variable names, but not allowing to jump to them if they are the same. But the parsing can indeed be quite tricky, we should only do it if it doesn't complicate the parser further.
One may restrict the alphanumeric line label only to continue statements except when continue is terminating a loop. Strictly speaking the assign statement is deleted feature, but I understand that the compilers have to support it anyway. As a deleted feature it may continue to use only numeric labels. The same for the do, the label if present, should be numeric. Moreover the new syntax may have the precedence. So your first case will be illegal, the second compilation error as assign needs a numeric label, the third compilation error without an enddo, and the last one print *,"or this one" as the new syntax should take the precedence.
On Fortran Discourse it was suggested (and I agree) that alphanumeric line labels be allowed, since
is more legible than