Ccompiler bug for concatenated strings in a condition

22 views
Skip to first unread message

Carlo Hogeveen

unread,
May 8, 2024, 2:28:34 PMMay 8
to Semware @ GoogleGroups

 

I ran into a small compiler bug today.

It feels familiar, so it might be a known one.

See the example macro below.

As demonstrated, it is very easy to work around.

 

Carlo

 

 

 

proc Main()

  //  Example of a compiler error that does not make sense

  //  according to TSE's "Precedence ..." documentation.

 

  //  This "if" statement is of course compilable.

  //  if 'ab' == ('a' + 'b')

 

  //  Unexpectedly this "if" statement is not compilable.

  if 'ab' == 'a' + 'b'

 

    Warn('Yes')

  else

    Warn('No')

  end

 

  PurgeMacro(CurrMacroFilename())

end Main

 

 

knud van eeden

unread,
May 8, 2024, 2:47:34 PMMay 8
to Semware @ GoogleGroups
Probably best to use the workaround of parentheses and just nothing this in e.g. the read.me as a known issue / bug.

Because it might break backwards existing source code which has a much larger collateral damage effect.

with friendly greetings
Knud van Eeden


--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/semware/000001daa175%2486416850%2492c438f0%24%40ecarlo.nl.

knud van eeden

unread,
May 8, 2024, 2:48:31 PMMay 8
to Semware @ GoogleGroups
Probably best to use the workaround of parentheses and just noting this in e.g. the read.me as a known issue / bug.

knud van eeden

unread,
May 8, 2024, 2:51:02 PMMay 8
to Semware @ GoogleGroups
In general changing the priority of operators like '==' and '+' is a very fundamental action which
can have large side effects thus in calculations / expressions and should not be changed (anymore).

knud van eeden

unread,
May 8, 2024, 2:57:58 PMMay 8
to Semware @ GoogleGroups
From the example I would thus at first glance assume that it is read as

( 'ab' == 'b' ) + 'c'

instead of the at the end of the day intended

'ab' == ( 'b' + 'c' )

From this follows that in the TSE expression parsing the operation '==' has *by definition* a higher
priority than '+'.

Thus the compiler error is actually not an error, but follows from its definition, so it is more of a
user error, and one *must* use parentheses to achieve what one wants.



S.E. Mitchell

unread,
May 9, 2024, 6:55:55 AMMay 9
to sem...@googlegroups.com
Yep, definitely a bug. + should have higher precedence than ==.
I'll add it to the list.
Reply all
Reply to author
Forward
0 new messages