Commit graph

245 commits

Author SHA1 Message Date
Jeong YunWon
fa6c66272e compile_with as recursive form 2022-08-11 07:45:30 +09:00
Jeong YunWon
a9306971ae Fix with-statement location 2022-08-11 07:14:20 +09:00
Jeong YunWon
75b886bcd6 enhance dis output to print line numbers 2022-08-11 07:14:20 +09:00
Jeong YunWon
1a09ba0ede max_stacksize -> max_stackdepth 2022-08-11 06:22:39 +09:00
Jeong YunWon
c3b1400240 Fix max_stacksize DEBUG to use const 2022-08-11 06:21:48 +09:00
Jeong YunWon
6760d21399 Fix break to contain end label 2022-08-11 02:01:34 +09:00
Jeong YunWon
3bf931fbb0 Fix comprehension bytecode generation 2022-08-10 05:32:48 +09:00
Myeongseon Choi
16d34ad5d2 Except operator cases from delete error rule 2022-07-20 18:10:42 +09:00
Myeongseon Choi
0b331cc916 Update del statement del [x] available 2022-07-20 18:10:15 +09:00
Myeongseon Choi
f869bc8371 Change error msg "can't" to "cannot" 2022-07-20 13:28:01 +09:00
Jeong Yunwon
46404a4665 Fix nightly clippy warnings 2022-06-24 01:13:32 +09:00
Jeong Yunwon
cb5324d023 Add compile::Mode::BlockExpr 2022-05-27 10:14:13 +09:00
Jeong Yunwon
2262971b12 Remove Instruction::MapAddRev 2022-05-20 08:23:24 +09:00
Jeong Yunwon
da3d41ce27 Fix comprehension instruction evaluation order 2022-05-20 08:23:24 +09:00
snowapril
dc1d6616ca 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
be43bfaa80 share comparisonop between bytecode and vm 2022-05-12 04:02:14 +09:00
Jeong Yunwon
f721781499 split comapre and richcompare instruction 2022-05-12 04:02:14 +09:00
Jeong Yunwon
33ddf76b26 fn -> impl FnOnce
https://github.com/RustPython/RustPython/pull/3674#discussion_r862511425
2022-05-02 18:08:26 +09:00
Jeong Yunwon
bbf475e212 compile get_doc -> split_doc to follow split_first convention in Rust 2022-05-02 10:37:47 +09:00
Jeong Yunwon
f97d1ed5d9 remove with_compiler 2022-05-02 10:37:47 +09:00
Jeong Yunwon
5e94f56ae4 compile_impl! => compile_impl 2022-05-02 10:37:47 +09:00
Jeong Yunwon
753c0337bc compile_single checks last expr out of loop 2022-05-02 10:37:45 +09:00
Jeong Yunwon
bedb508667 clean up imports and useless allow attributes 2022-04-15 23:58:20 +09:00
Noa
a4f34f64e9 Split Rotate into Rotate2 & Rotate3 2022-03-11 22:01:05 -06:00
Noa
e5eb2739b7 Fix augassign double-loading the container of the target 2022-03-10 13:27:38 -06:00
Noa
d9653b4895 Fix clippy warnings with 1.58 & convert some format strings to capture-args 2022-01-13 23:53:25 -06:00
Noa
4c3c5c5ed1 Add the __future__.annotations feature 2021-10-17 21:55:28 -05:00
Nixon Enraght-Moony
9d98f95a53 Bless Tests
This was broken by 54ab9cb54a0a9a637e1013a405dccdd8c52442a1

Closes #3253
2021-10-08 23:01:28 +01:00
jfh
6a19201eb4 Fix warnings for doc build. 2021-10-07 17:37:24 +03:00
Alex Muscar
e038799297 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
be92bc5243 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
d0c436949e Derive Default for CompileOpts 2021-09-30 03:59:18 +09:00
Padraic Fanning
ae122c6478 Replace master with main
Fixes #3067
2021-09-15 17:54:54 -04:00
Jeong YunWon
05fcfa8aa1 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
91ecc3df9a remove unnecessary mut in compiler.rs 2021-09-05 17:50:08 +09:00
HyeockJinKim
94e77ef8a6 Raise syntax error when saving a value to __debug__. 2021-08-27 23:48:14 +09:00
Jeong YunWon
acd73d21fe Compiler::qualified_name as vec 2021-08-27 23:45:47 +09:00
Jeong YunWon
88321d9319 clean up Compiler::create_qualified_name 2021-08-27 23:29:34 +09:00
Lee Dogeon
ca37219aff Fix __repr__, __qualname__ (#2977) 2021-08-27 17:07:10 +03:00
Nikita Sobolev
3289b9ccb4 Fixes typos in all other files 2021-08-22 12:42:13 +09:00
snowapril
416e2da7f6 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
0383dede81 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
9b0a82aed3 Fix unnessessary borrow 2021-07-30 02:32:16 +09:00
Padraic Fanning
5d639cc8de Fix manual_flatten Clippy warning 2021-05-07 16:57:38 -04:00
Noah
ab1dd4e2a4 Fix async for compilation 2021-04-11 17:38:44 -05:00
Noah
ee0af406e2 Add LoadMethod and CallMethod* opcodes 2021-03-15 09:45:07 -05:00
Noah
da0c85d2ac Impl Eq+Hash for ConstantData, make CodeInfo.constants an IndexSet 2021-03-11 09:58:25 -06:00
Noah
89c08246ba Fix SetupAsyncWith stack level handling 2021-02-20 21:04:30 -06:00
Noah
2b677d0124 Merge pull request #2438 from RustPython/coolreader18/compile_call-classdef
Handle splat args in bases/kwargs for __build_class__
2021-02-16 17:57:26 -06:00
Noah
5d1beacefa Handle splat args in bases/kwargs for __build_class__ 2021-02-15 21:39:43 -06:00