Synopsis - Issue Tracker

Bug156 Editing

Title synopsis aborts for str(template) if template has no name
Created on 2009-04-21.09:09:15 by tris, last changed 2009-04-27.14:08:58 by tris.
assigned to stefan priority normal
type behavior severity normal
components general platform GNU/Linux
status open resolution
depends on superseded by
Add Comment:
File
CC List:? hir, jsrinivasa, stefan, tris

Messages
Author: tris Date: 2009-04-21.09:09:08
due to this code fragment of ASG.py, working with the IR using str(template) when template has no defined name causes a crash.

class ParametrizedTypeId(TypeId):
[...]
    def __str__(self):
        return "%s<%s>"%('::'.join(self.template.name),
                         ','.join([str(a) for a in self.parameters]))
Author: stefan Date: 2009-04-21.13:57:37
Thanks for the report !

The input is invalid ('MyUnknownPairType' is undefined). Ideally, this should result in a 'parse error'. However, historically there were cases where Synopsis wouldn't be able to lookup a symbol, even if it was correctly declared. Thus I didn't make this a hard failure.

I do think that the code you quote (ASG.py) is right, i.e. it should assume 'template' to be an existing object, not None.
Synopsis may abort with a parse error prior to generating the ASG.
Author: tris Date: 2009-04-22.06:18:28
Hi,

c++ allows such definitions if the compiler is able to find the definition at compile time e.g template is defined before header include in the cpp file (here: defined in another header only included in cpp file).

i admit it is not a good coding style. 

in this case, the code belongs to someone else and i would like to analyse it (here: create a Rose model)

Regards,
 Tris

-------- Original-Nachricht --------
> Datum: Tue, 21 Apr 2009 13:57:49 +0000
> Von: Stefan Seefeld via synopsis issue tracker <issues@synopsis.fresco.org>
> An: hamster158-synopsis@yahoo.de, jsrinivasa@rambus.com, stefan@fresco.org, tris00@gmx.de
> Betreff: [bug156] synopsis aborts for str(template) if template has no name

> 
> Stefan Seefeld <stefan@fresco.org> added the comment:
> 
> Thanks for the report !
> 
> The input is invalid ('MyUnknownPairType' is undefined). Ideally, this
> should result in a 'parse error'. However, historically there were cases where
> Synopsis wouldn't be able to lookup a symbol, even if it was correctly
> declared. Thus I didn't make this a hard failure.
> 
> I do think that the code you quote (ASG.py) is right, i.e. it should
> assume 'template' to be an existing object, not None.
> Synopsis may abort with a parse error prior to generating the ASG.
> 
> ----------
> assignedto:  -> stefan
> nosy: +stefan
> status: new -> open
> 
> ___________________________________________________
> Synopsis issue tracker <issues@synopsis.fresco.org>
> <http://synopsis.fresco.org/issues/bug156>
> ___________________________________________________
Author: stefan Date: 2009-04-22.14:56:02
Sorry, no. The file you attached is not valid C++.
Please turn that into a valid C++ file and that still makes Synopsis fail, and I will try to resolve the issue.
Thanks !
Author: tris Date: 2009-04-27.14:08:58
Hi,

enclosed you get the header, the cpp, the Formatter and a shell script calling the compiler and synopsis.

as you will see, the cpp compiles without any problems.

synopsis aborts with
[...]
  File ".../Synopsis/ASG.py", line 200, in __str__
    ','.join([str(a) for a in self.parameters]))
  File ".../Synopsis/ASG.py", line 199, in __str__
    return "%s<%s>"%('::'.join(self.template.name),
AttributeError: 'NoneType' object has no attribute 'name'

as i wrote, i am not happy with this c++ programming "style"...

Regards,
 Tris

-------- Original-Nachricht --------
> Datum: Wed, 22 Apr 2009 14:56:07 +0000
> Von: Stefan Seefeld via synopsis issue tracker <issues@synopsis.fresco.org>
> An: hamster158-synopsis@yahoo.de, jsrinivasa@rambus.com, stefan@fresco.org, tris00@gmx.de
> Betreff: [bug156] synopsis aborts for str(template) if template has no name

> 
> Stefan Seefeld <stefan@fresco.org> added the comment:
> 
> Sorry, no. The file you attached is not valid C++.
> Please turn that into a valid C++ file and that still makes Synopsis fail,
> and I will try to resolve the issue.
> Thanks !
> 
> ___________________________________________________
> Synopsis issue tracker <issues@synopsis.fresco.org>
> <http://synopsis.fresco.org/issues/bug156>
> ___________________________________________________
Files
File nameUploaded
template_test.h tris, 2009-04-21.09:09:10
template_test.tgz tris, 2009-04-27.14:08:58
History
Date User Action Args
2009-04-21 09:09:29triscreate
2009-04-21 13:57:58stefansetstatus: new
assignedto: (no value)
messages: + msg745
nosy: + stefan
2009-04-22 06:18:29trissetmessages: + msg746
2009-04-22 14:56:08stefansetmessages: + msg747
2009-04-27 14:08:58trissetfiles: + template_test.tgz
messages: + msg748