Commit graph

185 commits

Author SHA1 Message Date
Noah
94eadd7137 Merge pull request #1951 from TheAnyKey/TheAnyKey/p38_named_expression_completion
Fix scope issue for non-locals
2020-06-10 16:36:12 -05:00
Noah
f7216a144a Fix Rust 1.44 clippy warnings 2020-06-06 15:37:47 -05:00
Noah
6708cef2a4 Fix compilation on redox 2020-06-02 15:21:33 -05:00
TheAnyKey
50c0b99136 fixed scoping issue for nonlocals - now also indirect outer scopes are supported 2020-06-01 22:47:28 +00:00
TheAnyKey
097b6a1889 Implement Py38 named expression (PEP 572) (#1934)
* Initial implementation of named expression and  import  according CPython tests

* added new instruction with inversed evaluation order for dict comprehension, in other cases use regular evaluation order

* added further aspects to implementation, cleaned up, imported test from CPython

* implemented first parts of scoping enhancement and extended checks

* completion of name resolution ongoing, now more test passing, still warinings and cleanup required

* further optimization of name resolution in nested scopes

* Initialize the vm with imports from _io instead of io

* Add the OpenBSD support that I am smart enough to

* adapted grammer to full support, most test are passing now, esp. all invalids are passed. Cleaned up in symboltable

* more conditional compiling, this time for errors

* rustfmt was not pleased

* premature push, whoops

* Add expected_failure result type to jsontests

* Initial implementation of named expression and  import  according CPython tests

* added new instruction with inversed evaluation order for dict comprehension, in other cases use regular evaluation order

* added further aspects to implementation, cleaned up, imported test from CPython

* implemented first parts of scoping enhancement and extended checks

* completion of name resolution ongoing, now more test passing, still warinings and cleanup required

* further optimization of name resolution in nested scopes

* adapted grammer to full support, most test are passing now, esp. all invalids are passed. Cleaned up in symboltable

* Fixed nameing convention violation and removed unnecessary information from symbol resolution. Added some more comments.

* Fixed nameing convention violation and removed unnecessary information from symbol resolution. Added some more comments.

Co-authored-by: Noah <33094578+coolreader18@users.noreply.github.com>
Co-authored-by: Reuben Staley <lighthousemaniac@gmail.com>
2020-06-01 11:22:15 +02:00
Jeong YunWon
1257331101 Fix unpack_ex related messages 2020-05-30 01:07:38 +00:00
Jeong YunWon
3f1b9c6096 Fix SyntaxError visualize order: message first location later 2020-05-30 01:07:38 +00:00
Jeong YunWon
0d139f9942 comprehension starred expression compatibility 2020-05-30 01:07:38 +00:00
Jeong YunWon
a77e0b8587 Distinguish MultipleStarArgs and InvalidStarArgs compile errors 2020-05-30 01:07:38 +00:00
Jeong YunWon
3f2b414fcc Merge pull request #1843 from RustPython/coolreader18/clippy-fixes
Fix some clippy lints that were previously 'allow'ed
2020-04-27 00:10:01 +09:00
Jeong YunWon
a9ea22ec2b Merge pull request #1880 from HyeockJinKim/issue1879
Remove unused variable
2020-04-26 00:12:26 +09:00
HyeockJinKim
e85baf4dfb Remove unused variable
Removed unused `is_param` variable for symbol.

Closes RustPython#1879
2020-04-25 13:59:54 +09:00
Noah
aba7359b36 Disable the unpack optimization 2020-04-24 15:14:58 -05:00
Noah
c27abf862f Fix some clippy lints that were 'allow'ed 2020-04-05 14:55:51 -05:00
Noah
1e12aa8afe Merge pull request #1834 from RustPython/coolreader18/jsontests
Add json output for CPython tests
2020-04-04 11:52:04 -05:00
Noah
8df7d73211 Fix clippy lints 2020-04-03 12:34:01 -05:00
Noah
9ac8969e0d Remove incognito from vm 2020-04-03 12:34:00 -05:00
Noah
ed09df8223 Make incognito a CodeFlag bit 2020-04-03 12:34:00 -05:00
Noah
a499fb775a Make from __future__ imports a syntactic construct in the compiler 2020-04-03 12:34:00 -05:00
Noah
330fdce246 Add "incognito" compilation 2020-04-03 12:34:00 -05:00
Noah
61dc0181e0 Move varargs information into CodeFlags 2020-04-02 09:02:18 -05:00
Noah
170719180a Apply review comments 2020-03-21 00:37:13 -05:00
Noah
7d6d5ff907 Fix syntax error tests 2020-03-21 00:35:36 -05:00
coolreader18
d5b9e6b93a Partially implement async generators 2020-03-21 00:33:46 -05:00
Noah
e9ff68c850 Improve compiler error creation 2020-03-13 23:26:07 -05:00
Noah
00f9d2247d Make bytecode::Location Copy 2020-03-13 21:49:10 -05:00
Noah
04606e9057 Make Location Copy and remove all location.clone()s 2020-03-13 21:49:10 -05:00
Jeong YunWon
867152880a positional only parameter support 2020-03-08 00:13:13 +09:00
Jeong YunWon
04c29f384e &str::to_string -> &str::to_owned for variables 2020-02-05 22:55:34 +09:00
Jeong YunWon
7860fc877d &str::to_string -> &str::to_owned for literals 2020-02-05 22:55:33 +09:00
Aviv Palivoda
9a599e81a4 Fix clippy warning 2019-12-27 10:27:51 +02:00
Aviv Palivoda
3827dbfc49 Parse FormattedValue spec in symboltable 2019-12-27 10:19:07 +02:00
Aviv Palivoda
de7f9efd54 Support expression in f-strings spec 2019-12-27 10:19:07 +02:00
Jeong YunWon
8adb8b5105 Fix clippy warnings 2019-12-21 18:49:48 +09:00
Jeong YunWon
23993c2833 implement SyntaxError attributes 2019-12-16 00:08:16 +09:00
Aviv Palivoda
aff1a6d53c Fix caret diagnostics for mutiple lines 2019-11-29 11:32:45 +02:00
yanganto
28fbdffdc8 Provide caret diagnostics for SyntaxError
visualize syntax error with caret diagnostics in shell, eval, exec,
when the error statement and error location are provided.
2019-11-22 09:17:50 +08:00
Noah
a51a3e0e4b Add a CompileContext 2019-11-07 00:04:51 -06:00
coolreader18
c39e0baab7 Add async for 2019-11-07 00:04:51 -06:00
Noah
19f62b97a3 Deduplicate async/normal with compilation code 2019-11-07 00:04:51 -06:00
coolreader18
ae825125a5 Add async with, reorganize how with blocks work 2019-11-07 00:04:51 -06:00
coolreader18
3638591cde Add coroutines, async/await functionality, and gen.close() 2019-11-07 00:04:50 -06:00
Aviv Palivoda
47c8f3756b Merge pull request #1580 from seeeturtle/doc-f
Set docstring of function as None if not declared
2019-11-02 19:18:11 +02:00
joshua1b
30ab196fdc Set docstring of function as None if not declared
In cpython, if there is no docstring declared in function definition,
the `__doc__` attribute of the function is None.
So this implements the behavior.

Fix #1523
2019-11-02 23:47:44 +09:00
ichyo
142a29be4a Fix wrong const optimization for "1.0 / 0.0" case
In cpython, "1.0 / 0.0" raises ZeroDivisionError
```
>>> 1.0 / 0.0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: float division by zer
```

but RustPython doesn't
```
>>>>> 1.0 / 0.0
inf
```

This is because they emits different byte codes.

```
$ echo "1.0 / 0.0" > zero-div.py

$ python -m dis zero-div.py
  1           0 LOAD_CONST               0 (1.0)
              2 LOAD_CONST               1 (0.0)
              4 BINARY_TRUE_DIVIDE
              6 POP_TOP
              8 LOAD_CONST               2 (None)
             10 RETURN_VALUE

$ cargo run --example dis zero-div.py
zero-div.py:
                 0 LoadConst            (inf)
                 1 Pop
                 2 LoadConst            (None)
                 3 ReturnValue
```

This commit stops optimization for zero division case
to generate same byte codes.
2019-10-24 00:26:02 +09:00
coolreader18
0fd098569e Change FunctionOpArg to CodeFlags, stored in CodeObject 2019-10-14 20:20:52 +00:00
ChJR
939b49dc81 Add build compatibility with rustc 1.36.0 since #1318 merged 2019-10-13 15:53:49 +09:00
Windel Bouwman
31b6e815f6 Merge pull request #1318 from youknowone/ast-module
ast module
2019-10-12 12:51:26 +02:00
Seo Sanghyeon
0000903a7d Shut up Clippy 2019-10-12 18:18:45 +09:00
Jeong YunWon
f2b696a75b Add mode to ast::parse 2019-10-12 18:12:36 +09:00