X512 wrote:Following sequence causes trap in compiler code:According language report this code seems to be valid. With without else doesn't crash.Code: Select all
WITH ELSE END;
issue-#125 Compiler TRAP for WITH statement
-
- Posts: 1700
- Joined: Tue Sep 17, 2013 12:21 am
- Location: Russia
issue-#125 Compiler TRAP for WITH statement
http://community.blackboxframework.org/ ... p=711#p665
-
- Posts: 1700
- Joined: Tue Sep 17, 2013 12:21 am
- Location: Russia
Re: issue-#125 Compile crashes on empty with
The diff
http://redmine.blackboxframework.org/pr ... 3e1d01b11f
Version for testing:
http://blackboxframework.org/unstable/i ... c1.637.zip
It seems to be ready for voting.
http://redmine.blackboxframework.org/pr ... 3e1d01b11f
Version for testing:
http://blackboxframework.org/unstable/i ... c1.637.zip
It seems to be ready for voting.
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
- Josef Templ
- Posts: 2047
- Joined: Tue Sep 17, 2013 6:50 am
Re: issue-#125 Compile crashes on empty with
The (hopefully) correct place and change for fixing this is in DevCPV486.stat.
Also the changes fold should be updated.
Please recreate the topic branch. The previous fixes are wrong because they change the language definition.
Such completely wrong attempts should not be in the repository because they make it hard to
see the important changes.
In the future please be more careful when proposing compiler changes.
It is very easy to mess things up in the compiler or language definition.
This is not something for a try-and-error approach.
Also the wording of the Redmine issue should be cleaned up.
Title: Compiler TRAP for WITH statement
Description: Compiling a statement of the form "WITH ELSE END" leads to a compiler TRAP.
- Josef
Code: Select all
| Nwith:
IF (n.left # NIL) OR (n.right # NIL) OR (n.subcl = 0) THEN IfStat(n, n.subcl = 0, next) END
instead of
IfStat(n, n.subcl = 0, next)
Please recreate the topic branch. The previous fixes are wrong because they change the language definition.
Such completely wrong attempts should not be in the repository because they make it hard to
see the important changes.
In the future please be more careful when proposing compiler changes.
It is very easy to mess things up in the compiler or language definition.
This is not something for a try-and-error approach.
Also the wording of the Redmine issue should be cleaned up.
Title: Compiler TRAP for WITH statement
Description: Compiling a statement of the form "WITH ELSE END" leads to a compiler TRAP.
- Josef
Last edited by Josef Templ on Thu Aug 25, 2016 8:54 am, edited 2 times in total.
Re: issue-#125 Compile crashes on empty with
it still astonishes me that bugs like this keep appearing in code that could have been stable, and has been in constant use for 20+ years.
Will it ever end?
Will it ever end?
-
- Posts: 204
- Joined: Wed Sep 18, 2013 10:06 pm
- Contact:
Re: issue-#125 Compile crashes on empty with
I wouldn't be too concerned if I were you. I would be more astonished to find an example of this particular use of WITH in a real world application.Robert wrote:it still astonishes me that bugs like this keep appearing in code that could have been stable, and has been in constant use for 20+ years.
Unless exceptional time and effort is invested in the development of an exhaustive compiler test suite many of these obscure edge cases might never be encountered.
-
- Posts: 1700
- Joined: Tue Sep 17, 2013 12:21 am
- Location: Russia
Re: issue-#125 Compiler TRAP for WITH statement
me too, treat it as a bug as first glance,it is ridiculous accepting such code by the compiler.cfbsoftware wrote:I would be more astonished to find an example of this particular use of WITH in a real world application.
-
- Posts: 1700
- Joined: Tue Sep 17, 2013 12:21 am
- Location: Russia
Re: issue-#125 Compiler TRAP for WITH statement
It seems that Josef is right for this case.luowy wrote:me too, treat it as a bug as first glance,it is ridiculous accepting such code by the compiler.cfbsoftware wrote:I would be more astonished to find an example of this particular use of WITH in a real world application.
So WITH ELSE END is correct meaningless construction...9.11 With Statements
With statements execute a statement sequence depending on the result of a type test and apply a type guard to every occurrence of the tested variable within this statement sequence.
WithStatement = WITH [ Guard DO StatementSequence ]
{"|" [ Guard DO StatementSequence ] }
[ELSE StatementSequence] END.
Guard = Qualident ":" Qualident.
If v is a variable parameter of record type or a pointer variable, and if it is of a static type T0, the statement
WITH v: T1 DO S1 | v: T2 DO S2 ELSE S3 END
has the following meaning: if the dynamic type of v is T1, then the statement sequence S1 is executed where v is regarded as if it had the static type T1; else if the dynamic type of v is T2, then S2 is executed where v is regarded as if it had the static type T2; else S3 is executed. T1 and T2 must be extensions of T0. If no type test is satisfied and if an else clause is missing the program is aborted.
Example:
WITH t: CenterTree DO i := t.width; c := t.subnode END
-
- Posts: 1700
- Joined: Tue Sep 17, 2013 12:21 am
- Location: Russia
Re: issue-#125 Compiler TRAP for WITH statement
I have tested the version 1.7-rc1.642
http://blackboxframework.org/unstable/i ... c1.642.zip
Not trap. And all is working.
http://blackboxframework.org/unstable/i ... c1.642.zip
Not trap. And all is working.