Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SyntaxError of global declaration don't stop program #72

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

Closed
HyeockJinKim opened this issue Sep 8, 2019 · 6 comments Β· Fixed by #74
Closed

SyntaxError of global declaration don't stop program #72

HyeockJinKim opened this issue Sep 8, 2019 · 6 comments Β· Fixed by #74
Assignees
Labels
bug Something isn't working Contributhon2019

Comments

@HyeockJinKim
Copy link
Contributor

a = 3
global a
print(a)

b = 2 + 5
print(b)

This code generate syntax error, but gpython doesn't stop program

Expected Result

Hyeockz:bin hyeockjinkim$ python3 g.py 
  File "g.py", line 2
    global a
SyntaxError: name 'a' is assigned to before global declaration

Actual Result

2019/09/09 00:08:36 name 'a' is assigned to before global declaration
3
7

SyntaxError in python3 is Error, not warning. So I think it should be modified.

@HyeockJinKim
Copy link
Contributor Author

If this issue is valid, can I take it?

@ncw
Copy link
Collaborator

ncw commented Sep 8, 2019

Interesting, that behaviour has changed from python3.4 to python3.7

Gpython is following python3.4 for the moment so it should be generating a SyntaxWarning

$ /opt/python3.4/bin/python3.4 /tmp/z.py 
/tmp/z.py:2: SyntaxWarning: name 'a' is assigned to before global declaration
  global a
3
7
$ python3.7 /tmp/z.py 
  File "/tmp/z.py", line 2
    global a
    ^
SyntaxError: name 'a' is assigned to before global declaration

If this issue is valid, can I take it?

Happy to have help, so yes!

@ncw ncw added the bug Something isn't working label Sep 8, 2019
@corona10
Copy link
Collaborator

corona10 commented Sep 8, 2019

@ncw
FYI, @HyeockJinKim is a mentee of OSS program named Contributhon of Korea government.
It's a similar program like GSoC.
(A few months ago I posted a mailing list about this program )
I am mentoring @HyeockJinKim for a month.

There are also some people(4-5) who want to contribute gpython project for the first time.
so they need our help too.

And I am going to assign issues to them with Contributhon 2019tag. (It is the program name)

@corona10
Copy link
Collaborator

corona10 commented Sep 8, 2019

cc @sbinet

@ncw
Copy link
Collaborator

ncw commented Sep 9, 2019

Fantastic news @corona10 - what a great project! Ping me on an issue if you need help :-)

@sbinet
Copy link
Member

sbinet commented Sep 10, 2019

and welcome in the wonderful world of mentoring :)

HyeockJinKim added a commit to HyeockJinKim/gpython that referenced this issue Sep 10, 2019
Generate SyntaxError instead of SyntaxWarning
if global declaration is for priviously used variable

Fixes go-python#72
corona10 pushed a commit that referenced this issue Sep 15, 2019
* Generate SyntaxError of global declaration

Generate SyntaxError instead of SyntaxWarning
if global declaration is for priviously used variable

Fixes #72

* Modify symtable test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Contributhon2019
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants