Repository: chanzuckerberg/miniwdl

Issue:
calling str() on some functions results in AttributeError: [...] object has no attribute 'name'
I just found a bug in my implementation of the `__str__` function for expressions (#215). For any functions which do not inherit the `StaticFunction` class the `name` attribute doesn't exist. Which will result in an error when calling `str` on (some of) these functions.

I am currently investigating how to solve this and will make a PR when I find a solution.

Discussion:
coveralls: ## Pull Request Test Coverage Report for [Build 1138](https://coveralls.io/builds/25867385)

* **2** of **2**   **(100.0%)**  changed or added relevant lines in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **96.943%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/25867385/badge)](https://coveralls.io/builds/25867385) |
| :-- | --: |
| Change from base [Build 1129](https://coveralls.io/builds/25792618): |  0.0% |
| Covered Lines: | 4344 |
| Relevant Lines: | 4481 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/WDL/Expr.py b/WDL/Expr.py
index 40ec922..86b61ef 100644
--- a/WDL/Expr.py
+++ b/WDL/Expr.py
@@ -1031,9 +1031,9 @@ class Apply(Base):
             return "{} && {}".format(arguments[0], arguments[1])
         elif isinstance(func, StdLib._Or):
             return "{} || {}".format(arguments[0], arguments[1])
-        elif func.name == "_rem":
+        elif self.function_name == "_rem":
             return "{} % {}".format(arguments[0], arguments[1])
-        elif func.name == "_negate":
+        elif self.function_name == "_negate":
             return "!{}".format(arguments[0])
         else:
             return "{}({})".format(self.function_name, ",".join(arguments))


Test patch:
diff --git a/tests/test_0eval.py b/tests/test_0eval.py
index 4dbf499..2dcdee3 100644
--- a/tests/test_0eval.py
+++ b/tests/test_0eval.py
@@ -38,6 +38,7 @@ class TestEval(unittest.TestCase):
 
         # functions
         self.assertEqual(str(WDL.parse_expr("defined(value)")), "defined(value)")
+        self.assertEqual(str(WDL.parse_expr("select_first([1, 2])")), "select_first([1, 2])")
 
         # access
         self.assertEqual(str(WDL.parse_expr("[1,2][1]")), "[1, 2][1]")