Skip to content

Local (nested) classes only one level deep #120

@axgkl

Description

@axgkl

Hey Jacques,

its alive ;-)

After finishing developing our container orchestration I will now go work further on an application framework for the GUI, clearly using the one and only Transcrypt!

Its amazing how much progress Transcrypt made, absolutely slick meanwhile. "Works as expected" is really an understatement and I'm happy to see you find time for esoteric stuff like type mgmt ;-)


One thing I found though, regarding local (nested) class handling, and I think there is a somewhat cheap fix:

class T1:                                                                       
    class T2:                                                                   
        class T3:                                                               
            class T4: pass                     

is compiled into

        var T1 = __class__ ('T1', [object], {
        });
        T1.T2 = __class__ ('T2', [object], {
        });
        T2.T3 = __class__ ('T3', [object], {
        });
        T3.T4 = __class__ ('T4', [object], {
        });

works for T2, i.e. one nested level but not deeper.

E.g. T2.T3 = ..., should be e.g. T1.T2.T3 = ...

i.e. instead of just taking the parent here...

if type (self.getScope () .node) == ast.ClassDef:
    self.emit ('{}.{}'.format (self.filterId (self.getScope () .node.name), self.filterId (node.name)))

... we should go 'up/outside' and stop only when container is module. Maybe by remembering the container nodes and their names in a cache or so (?)

I'm a bit in time pressure so I can't create a PR for that, sorry, but maybe you also find it straight forward(?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions