@Test
public void cannot_serialize_illegal_expression() {

  Expression illegalExpr = new Expression() {
    private final Object object = new Object(); // non-serializable
    @Override
    public ExprValue valueOf(Environment<Expression, ExprValue> valueEnv) {
      return null;
    }
    @Override
    public ExprType type() {
      return null;
    }
    @Override
    public <T, C> T accept(ExpressionNodeVisitor<T, C> visitor, C context) {
      return null;
    }
  };
  assertThrows(IllegalStateException.class, () -> serializer.serialize(illegalExpr));
}