Skip to content

Commit

Permalink
Merge 89df7a0 into af428e6
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Apr 10, 2019
2 parents af428e6 + 89df7a0 commit 519a3a1
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 85 deletions.
8 changes: 4 additions & 4 deletions WDL/Env.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Binding:
name: str
":type: str"
rhs: Any
""":type: Union[WDL.Type.Base,WDL.Value.Base,WDL.StructType,WDL.Decl.Base]
""":type: Union[WDL.Type.Base,WDL.Value.Base,WDL.StructTypeDef,WDL.Decl.Base]
"Right-hand side" of the binding"""

Expand Down Expand Up @@ -77,7 +77,7 @@ def __repr__(self):
Once constructed, environments should be considered immutable. There should be
no name or namespace collisions.
``WDL.Env.{Types,Values,StructTypes,Decls}`` are type aliases for ``Tree``
``WDL.Env.{Types,Values,StructTypeDefs,Decls}`` are type aliases for ``Tree``
with the respective `Binding.rhs` type.
"""

Expand All @@ -91,8 +91,8 @@ def __repr__(self):
Values = Tree
""":type: WDL.Env.Tree[WDL.Value.Base]"""

StructTypes = Tree
""":type: WDL.Env.Tree[WDL.Tree.StructType]"""
StructTypeDefs = Tree
""":type: WDL.Env.Tree[WDL.Tree.StructTypeDef]"""

Decls = Tree
""":type: WDL.Env.Tree[WDL.Tree.Decl]"""
Expand Down
4 changes: 2 additions & 2 deletions WDL/Expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,13 @@ def _infer_type(self, type_env: Env.Types) -> T.Base:
member_types = {}
for k, v in self.members.items():
member_types[k] = v.type
return T.ObjectLiteral(member_types)
return T.Object(member_types)

def eval(self, env: Env.Values) -> V.Base:
ans = {}
for k, v in self.members.items():
ans[k] = v.eval(env)
assert isinstance(self.type, T.ObjectLiteral)
assert isinstance(self.type, T.Object)
return V.Struct(self.type, ans)


Expand Down
26 changes: 14 additions & 12 deletions WDL/Lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ def call(self, obj: WDL.Call) -> Any:
if doc.workflow and doc.workflow.name == obj.name:
msg = "call name '{}' collides with workflow name".format(obj.name)
self.add(obj, msg)
for stb in doc.struct_types:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructType)
for stb in doc.struct_typedefs:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructTypeDef)
if stb.name == obj.name:
msg = "call name '{}' colides with {}struct type".format(
obj.name, "imported " if stb.rhs.imported else ""
Expand All @@ -495,8 +495,8 @@ def decl(self, obj: WDL.Decl) -> Any:
if obj.name == task.name:
msg = "declaration of '{}' collides with a task name".format(obj.name)
self.add(obj, msg)
for stb in doc.struct_types:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructType)
for stb in doc.struct_typedefs:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructTypeDef)
if stb.name == obj.name:
msg = "declaration of '{}' colides with {}struct type".format(
obj.name, "imported " if stb.rhs.imported else ""
Expand All @@ -521,8 +521,8 @@ def scatter(self, obj: WDL.Tree.Scatter) -> Any:
if obj.variable == task.name:
msg = "scatter variable '{}' collides with a task name".format(obj.variable)
self.add(obj, msg)
for stb in doc.struct_types:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructType)
for stb in doc.struct_typedefs:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructTypeDef)
if stb.name == obj.variable:
msg = "scatter variable '{}' colides with {}struct type".format(
obj.variable, "imported " if stb.rhs.imported else ""
Expand All @@ -540,8 +540,8 @@ def workflow(self, obj: WDL.Workflow) -> Any:
obj.name
)
self.add(obj, msg)
for stb in doc.struct_types:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructType)
for stb in doc.struct_typedefs:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructTypeDef)
if stb.name == obj.name:
msg = "workflow name '{}' colides with {}struct type".format(
obj.name, "imported " if stb.rhs.imported else ""
Expand All @@ -557,8 +557,8 @@ def task(self, obj: WDL.Task) -> Any:
if imp.namespace == obj.name:
msg = "task name '{}' collides with imported document namespace".format(obj.name)
self.add(obj, msg)
for stb in doc.struct_types:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructType)
for stb in doc.struct_typedefs:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructTypeDef)
if stb.name == obj.name:
msg = "task name '{}' colides with {}struct type".format(
obj.name, "imported " if stb.rhs.imported else ""
Expand All @@ -567,8 +567,10 @@ def task(self, obj: WDL.Task) -> Any:

def document(self, obj: WDL.Tree.Document) -> Any:
for imp in obj.imports:
for stb in obj.struct_types:
assert isinstance(stb, WDL.Env.Binding) and isinstance(stb.rhs, WDL.Tree.StructType)
for stb in obj.struct_typedefs:
assert isinstance(stb, WDL.Env.Binding) and isinstance(
stb.rhs, WDL.Tree.StructTypeDef
)
if stb.name == imp.namespace:
msg = "imported document namespace '{}' collides with {}struct type".format(
imp.namespace, "imported " if stb.rhs.imported else ""
Expand Down
Loading

0 comments on commit 519a3a1

Please sign in to comment.