Bug 5111 - translator silently ignores "then" instead of "{"
Summary: translator silently ignores "then" instead of "{"
Status: RESOLVED DUPLICATE of bug 1119
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-04 23:15 UTC by Dave Nomura
Modified: 2007-10-05 00:18 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Nomura 2007-10-04 23:15:07 UTC
In the following tapscript I unwittingly inserted "then" in an if stmt.  The
translator accepted this without complaint, but basically ignored the if.

I was expecting a syntax error.  Is this a legal if stmt?

function func:long ()
%{
        THIS->__retvalue = -1;
%}

probe begin
{
        if (func() < 0) then
                print("why no syntax error\n")
        printf("after if stmt\n")
}
Comment 1 Josh Stone 2007-10-05 00:02:08 UTC
Several features of the language are conspiring to bite you here: implicit
variable declarations, optional braces around a single statement, and optional
statement terminators.  So this:

>         if (func() < 0) then
>                 print("why no syntax error\n")

is effectively parsed as this:

    if (func() < 0) {
        then;
    }
    print("why no syntax error\n")

The parser thinks that 'then' is a variable, and the optimizer determines that
'then;' has no effect, so it is thrown away.  If you pass '-u' to stap, it will
throw an unresolved type for 'then'.

We may need a translator warning when it encounters such statements, with no
assigments and no function calls.
Comment 2 Frank Ch. Eigler 2007-10-05 00:18:21 UTC
an oldie but goodie


*** This bug has been marked as a duplicate of 1119 ***