# Valuation error when composing power series

I'm trying to work with power series with coefficients in a ring consisting of elements $f/g$, where $f$ is a polynomial in several variables over the integers and g is a polynomial in one of those variables with unit constant coefficient. Ultimately, I'd like to be able to do all of the following:

- Compose power series over this ring
- Invert single-variable power series over this ring whose degree-1 coefficients are units
- Reduce the coefficients of a power series modulo some ideal of the ring

I thought I would do this by starting with the Laurent series over $\mathbf{Z}$ in the variable that occurs in the denominator, constructing a polynomial ring over this by adjoining the other variables, and letting my power series take coefficients in this ring. But I'm getting an error I don't understand when I try to compose series. The following example illustrates the problem:

```
M1.<b> = LaurentSeriesRing(ZZ)
M.<a,c> = PolynomialRing(M1)
R.<t1,t2> = PowerSeriesRing(M)
X = t1 + t2 + O(t1,t2)^3
R1.<t> = PowerSeriesRing(M)
f = X(t,t^2); f
```

This returns the type error `Substitution defined only for elements of positive valuation, unless self has infinite precision`

despite the fact that replacing the last line by `t.valuation()`

or `(t^2).valuation()`

returns `1`

or `2`

, respectively.

The problem seems to result from a combination of factors. If I replace the second line with either

```
M.<a,c> = PolynomialRing(ZZ)
```

or

```
M.<a> = PolynomialRing(M1)
```

the error vanishes and the code returns the expected `t + t^2 + O(t)^3`

. It also gives no error if I define `R`

and `R1`

to be polynomial rings, rather than power series rings, over `M`

(and correspondingly delete the big-O notation).

Any ideas about what is triggering the error, or another way to construct these power series?