浏览代码

Fix boolean parsing;

bjorn 9 年之前
父节点
当前提交
31b56f7917
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      types.lua

+ 6 - 2
types.lua

@@ -199,7 +199,7 @@ types.string = types.scalar({
 })
 })
 
 
 local function toboolean(x)
 local function toboolean(x)
-  return x and true or false
+  return (x and x ~= 'false') and true or false
 end
 end
 
 
 types.boolean = types.scalar({
 types.boolean = types.scalar({
@@ -207,7 +207,11 @@ types.boolean = types.scalar({
   serialize = toboolean,
   serialize = toboolean,
   parseValue = toboolean,
   parseValue = toboolean,
   parseLiteral = function(node)
   parseLiteral = function(node)
-    return node.kind == 'boolean' and node.value or nil
+    if node.kind == 'boolean' then
+      return toboolean(node.value)
+    else
+      return nil
+    end
   end
   end
 })
 })