8000 Type checking for == · mlviz/pseudo-python@13a6949 · GitHub
[go: up one dir, main page]

Skip to content

Commit 13a6949

Browse files
committed
Type checking for ==
1 parent b189e56 commit 13a6949

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

CHANGELOG.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
0.2.26
2+
3+
18.03.2016
4+
5+
Features:
6+
7+
* Type checking for ==
8+
19
0.2.22
210

3-
17.03.2016
11+
17.03.2016
412

5-
Fixes:
13+
Fixes:
614

7-
* Fix unary op handling
8-
* Convert ** to `math:pow`
15+
* Fix unary op handling
16+
* Convert ** to `math:pow`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A restricted Python to idiomatic JavaScript / Ruby / Go / C# translator
77

88
[Pseudo](https://github.com/alehander42/pseudo) is a framework for high level code generation: it is used by this compiler to translate a subset of Python to all Pseudo-supported languages
99

10-
**If you are using Python3.5 and you experience problems with an already installed version of pseudo-python, please upgrade it to `0.2.22` (`pip3 install pseudo-python --upgrade`)**
10+
**If you are using Python3.5 and you experience problems with an already installed version of pseudo-python, please upgrade it to `0.2.26` (`pip3 install pseudo-python --upgrade`)**
1111

1212

1313

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.22
1+
0.2.26

pseudo_python/ast_translator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ def _translate_compare(self, left, ops, comparators, location):
910910
right_node = self._translate_node(comparators[0])
911911
left_node = self._translate_node(left)
912912

913-
self._confirm_comparable(left_node['pseudo_type'], right_node['pseudo_type'], location)
913+
self._confirm_comparable(op, left_node['pseudo_type'], right_node['pseudo_type'], location)
914914

915915
result = {
916916
'type': 'comparison',
@@ -924,7 +924,7 @@ def _translate_compare(self, left, ops, comparators, location):
924924
else:
925925
for r in comparators[1:]:
926926
left_node, right_node = right_node, self._translate_node(r)
927-
self._confirm_comparable(left_node['pseudo_type'], right_node['pseudo_type'], location)
927+
self._confirm_comparable(op, left_node['pseudo_type'], right_node['pseudo_type'], location)
928928
result = {
929929
'type': 'binary_op',
930930
'op': 'and',
@@ -947,9 +947,9 @@ def _confirm_index(self, index_type, expected, location, window):
947947
location, self.lines[location[0]],
948948
wrong_type=index_type)
949949

950-
def _confirm_comparable(self, l, r, location):
951-
if isinstance(l, list) or isinstance(r, list) or\
952-
l != r or l not in COMPARABLE_TYPES:
950+
def _confirm_comparable(self, o, l, r, location):
951+
if o == '==' and l != r or o != '==' and (isinstance(l, list) or isinstance(r, list) or\
952+
l != r or l not in COMPARABLE_TYPES):
953953
raise type_check_error(
954954
'%s not comparable with %s' % (serialize_type(l), serialize_type(r)),
955955
location, self.lines[location[0]],

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='pseudo-python',
5-
version='0.2.22',
5+
version='0.2.26',
66
description='a python3 to pseudo compiler',
77
author='Alexander Ivanov',
88
author_email='alehander42@gmail.com',

0 commit comments

Comments
 (0)
0