Author: Stephan <[email protected]>
Branch: 
Changeset: r246:f0379d63ff8a
Date: 2012-06-03 15:24 +0200
http://bitbucket.org/pypy/lang-js/changeset/f0379d63ff8a/

Log:    fixed type of null

diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -91,13 +91,13 @@
         raise JsTypeError()
 
 class W_Null(W_Primitive):
-    _type_ = 'object'
+    _type_ = 'null'
 
     def ToBoolean(self):
         return False
 
     def to_string(self):
-        return self._type_
+        return 'null'
 
     def check_object_coercible(self):
         raise JsTypeError()
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -232,10 +232,18 @@
         has_name = right.has_property(name)
         return newbool(has_name)
 
+# 11.4.3
+def type_of(var):
+    var_type = var.type()
+    if var_type == 'null':
+        return 'object'
+    return var_type
+
 class TYPEOF(BaseUnaryOperation):
     def eval(self, ctx):
         var = ctx.stack_pop()
-        ctx.stack_append(W_String(var.type()))
+        var_type = type_of(var)
+        ctx.stack_append(_w(var_type))
 
 class TYPEOF_VARIABLE(Opcode):
     def __init__(self, index, name):
@@ -248,7 +256,7 @@
             var_type = 'undefined'
         else:
             var = ref.get_value()
-            var_type = var.type()
+            var_type = type_of(var)
         ctx.stack_append(W_String(var_type))
 
     def __str__(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to