Commit Graph

270 Commits

Author SHA1 Message Date
Jeong YunWon
53b344866f Implement new features for updated python asdl 2022-08-19 04:52:45 +09:00
Jeong YunWon
089eafeabd update asdl_rs.py for updated Python.asdl 2022-08-19 04:52:45 +09:00
Jeong YunWon
b476c56deb replace try_parse!() macro to closure 2022-08-12 08:35:34 +09:00
Jeong YunWon
421de1a032 compile_with as recursive form 2022-08-11 07:45:30 +09:00
Jeong YunWon
15aad7cb94 Fix with-statement location 2022-08-11 07:14:20 +09:00
Jeong YunWon
4f0ed88d66 enhance dis output to print line numbers 2022-08-11 07:14:20 +09:00
Jeong YunWon
c9e865aff3 max_stacksize -> max_stackdepth 2022-08-11 06:22:39 +09:00
Jeong YunWon
02029c4057 Fix max_stacksize DEBUG to use const 2022-08-11 06:21:48 +09:00
Jeong YunWon
ffc3e1352a Fix break to contain end label 2022-08-11 02:01:34 +09:00
Jeong YunWon
425c2b4bc4 Fix comprehension bytecode generation 2022-08-10 05:32:48 +09:00
c66d22da84 Except operator cases from delete error rule 2022-07-20 18:10:42 +09:00
da2695cffd Update del statement del [x] available 2022-07-20 18:10:15 +09:00
3c07c7ce00 Change error msg "can't" to "cannot" 2022-07-20 13:28:01 +09:00
Jeong Yunwon
8c0be4b48f Fix nightly clippy warnings 2022-06-24 01:13:32 +09:00
Jeong Yunwon
beff32a2a3 Add compile::Mode::BlockExpr 2022-05-27 10:14:13 +09:00
Jeong Yunwon
d58ddd21ce Remove Instruction::MapAddRev 2022-05-20 08:23:24 +09:00
Jeong Yunwon
503a1474f5 Fix comprehension instruction evaluation order 2022-05-20 08:23:24 +09:00
snowapril
689c0b6c5b Add missing codes for empty statement body
Fix #3704
Compared to previous version of `compile_program_single`, below two
codes are skipped when an empty body is given.
```rust
self.emit_constant(ConstantData::None);
self.emit(Instruction::ReturnValue);
```

Signed-off-by: snowapril <sinjihng@gmail.com>
2022-05-16 11:51:49 +09:00
Jeong Yunwon
7df0acd6b6 share comparisonop between bytecode and vm 2022-05-12 04:02:14 +09:00
Jeong Yunwon
53d835faa7 split comapre and richcompare instruction 2022-05-12 04:02:14 +09:00
Jeong Yunwon
75b3e0d0e3 fn -> impl FnOnce
https://github.com/RustPython/RustPython/pull/3674#discussion_r862511425
2022-05-02 18:08:26 +09:00
Jeong Yunwon
13e602b1df compile get_doc -> split_doc to follow split_first convention in Rust 2022-05-02 10:37:47 +09:00
Jeong Yunwon
852afd5424 remove with_compiler 2022-05-02 10:37:47 +09:00
Jeong Yunwon
2f62bb51c2 compile_impl! => compile_impl 2022-05-02 10:37:47 +09:00
Jeong Yunwon
50e6146b23 compile_single checks last expr out of loop 2022-05-02 10:37:45 +09:00
Jeong Yunwon
965c3157c8 Upgrade libraries 2022-04-18 00:09:22 +09:00
Jeong Yunwon
6357a1acbe clean up imports and useless allow attributes 2022-04-15 23:58:20 +09:00
Noa
f93b134b69 Split Rotate into Rotate2 & Rotate3 2022-03-11 22:01:05 -06:00
Noa
f04a305ac6 Fix augassign double-loading the container of the target 2022-03-10 13:27:38 -06:00
Noa
1188369956 Fix clippy warnings with 1.58 & convert some format strings to capture-args 2022-01-13 23:53:25 -06:00
Noa
358ce09b5c Run cargo upgrade 2021-10-30 19:42:35 -05:00
Noa
ee8b11f5d2 Migrate to 2021 edition 2021-10-21 11:46:24 -05:00
Noa
f6101a5821 Add the __future__.annotations feature 2021-10-17 21:55:28 -05:00
Noa
27540e1d35 Add unparse feature to ast 2021-10-17 21:55:27 -05:00
Nixon Enraght-Moony
98aa4bbe06 Bless Tests
This was broken by 54ab9cb54a

Closes #3253
2021-10-08 23:01:28 +01:00
jfh
1f78c764ad Fix warnings for doc build. 2021-10-07 17:37:24 +03:00
Alex Muscar
46f070b14d Consolidate error handling for builtin "constants" mutations
Co-authored-by: Jeong YunWon <youknowone@users.noreply.github.com>
2021-10-05 09:11:42 +01:00
Alex Muscar
94ae5a3af8 fix: forbid stores to the __debug__ builtin #3203
According to [the docs][1], `__debug__` is treated as a constant by the
interpreter.

This patch adds some checks to bring RustPython's behaviour in line with
cpython's.

[1]: https://docs.python.org/3/library/constants.html#built-in-constants
2021-10-05 09:11:42 +01:00
Jeong YunWon
4c8b14d2f1 Derive Default for CompileOpts 2021-09-30 03:59:18 +09:00
Padraic Fanning
0ea56025ec Replace master with main
Fixes #3067
2021-09-15 17:54:54 -04:00
Jeong YunWon
64f7599de7 Merge pull request #2980 from HyeockJinKim/debug_value
Raise syntax error when saving a value to __debug__.
2021-09-06 01:58:36 +09:00
HyeockJinKim
85ec817b73 remove unnecessary mut in compiler.rs 2021-09-05 17:50:08 +09:00
HyeockJinKim
e5137fd25f Raise syntax error when saving a value to __debug__. 2021-08-27 23:48:14 +09:00
Jeong YunWon
93b91bab2d Compiler::qualified_name as vec 2021-08-27 23:45:47 +09:00
Jeong YunWon
390005f9a8 clean up Compiler::create_qualified_name 2021-08-27 23:29:34 +09:00
Lee Dogeon
abdfe3222b Fix __repr__, __qualname__ (#2977) 2021-08-27 17:07:10 +03:00
Nikita Sobolev
ba74a9a239 Fixes typos in all other files 2021-08-22 12:42:13 +09:00
snowapril
38237c30d3 compiler: add is_global() check at top of errors
add `!symbol.is_global()` condition check before entrying global symbol
errors

This change will decrease hot path cost.

Signed-off-by: snowapril <sinjihng@gmail.com>
2021-08-18 00:35:14 +09:00
snowapril
13bbefdd4e compiler: impl syntax error detect for global kind
This commit fixes `test_global_parap_err_first` test in
[test_syntax.py](https://github.com/RustPython/RustPython/blob/master/Lib/test/test_syntax.py#L678) and implement the other syntax errors detection as cpython 3.8 provided for global symbol.

Below syntax error conditions are added.
* name {} is parameter and global
```python
>>>>> def test(a):
.....   global a
.....
SyntaxError: name 'a' is parameter and global at line 2 column 2
        global a
```
* annotated name {} can't be global
```python
>>>>> def test():
.....   a: int
.....   global a
.....
SyntaxError: annotated name 'a' can't be global at line 3 column 2
        global a
```
* name {} is assigned to before global description
```python
>>>>> a = 100
>>>>> def test():
.....   a = 10
.....   global a
.....
SyntaxError: name 'a' is assigned to before global declaration at line 3 column 2
        global a
```
* name {} is used prior to global declaration
```python
>>>>> a = 10
>>>>> def test():
.....   print(a)
.....   global a
.....
SyntaxError: name 'a' is used prior to global declaration at line 3 column 2
        global a
```

Signed-off-by: snowapril <sinjihng@gmail.com>
2021-08-17 21:14:13 +09:00
Jeong YunWon
ff4efd0f60 Fix unnessessary borrow 2021-07-30 02:32:16 +09:00