Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: class static member scope #663

Open
Andrei-Pozolotin opened this issue Aug 23, 2019 · 2 comments
Open

BUG: class static member scope #663

Andrei-Pozolotin opened this issue Aug 23, 2019 · 2 comments

Comments

@Andrei-Pozolotin
Copy link

Andrei-Pozolotin commented Aug 23, 2019

  1. in python and brython the following works fine:
    https://www.brython.info/tests/editor.html?lang=en
class DataUnit:
   static_one = 'one'
   static_two = 'two'
   static_total = static_one + static_two
  1. in transcrypt, generated js uses direct mapping
...
{
   static_one : 'one',
   static_two : 'two',
   static_total : static_one + static_two // SCOPE NOT AVAILABLE
}
  1. solution: generated js could use class prefix:
...
{
   static_one : 'one',
   static_two : 'two',
   static_total : DataUnit.static_one + DataUnit.static_two,
}
@Andrei-Pozolotin
Copy link
Author

additional problem with static scope: it is not executed

class DataUnit:
   print('this is not printed')

@AlexECX
Copy link

AlexECX commented Aug 30, 2019

Could be merged with #630. Also note that when the initializer object is used to create the class, DataUnit does not exist yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants