mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Merge pull request #404 from github/none-is-the-loneliest-umber
Compile Python None expressions.
This commit is contained in:
commit
ae6b2849f2
@ -341,7 +341,11 @@ instance Compile Py.Module where
|
||||
in fmap (locate it) . foldr compile buildRecord stmts
|
||||
|
||||
instance Compile Py.NamedExpression
|
||||
instance Compile Py.None
|
||||
|
||||
instance Compile Py.None where
|
||||
-- None is not overridable, and thus always points to the prelude's None.
|
||||
compile _it cc _ = cc (pure "__semantic_prelude" ... "None")
|
||||
|
||||
instance Compile Py.NonlocalStatement
|
||||
instance Compile Py.NotOperator
|
||||
|
||||
|
@ -10,8 +10,16 @@
|
||||
|
||||
str <- type "str" object #record { __new__: \prim -> instance #unit prim #record{} };
|
||||
|
||||
NoneType <- type "None" object #record { __new__: \prim -> instance #unit prim #record{} };
|
||||
None <- NoneType.__slots.__new__ #unit;
|
||||
|
||||
getitem <- \super -> \item -> \attr ->
|
||||
if item.slots.?attr then item.slots.attr else #unit;
|
||||
|
||||
#record { type: type, object: object, str: str, getitem: getitem}
|
||||
#record { type: type
|
||||
, object: object
|
||||
, str: str
|
||||
, NoneType: NoneType
|
||||
, None: None
|
||||
, getitem: getitem}
|
||||
}
|
||||
|
2
semantic-python/test/fixtures/4-02-nonetype.py
vendored
Normal file
2
semantic-python/test/fixtures/4-02-nonetype.py
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# CHECK-TREE: { x <- __semantic_prelude.None; #record { x : x }}
|
||||
x = None
|
Loading…
Reference in New Issue
Block a user