I am encountering problems in Mathematica that can be illustrated by this minimal example:

```
f[x_] := Sum[If[n + x > 0, 2^n, 0], {n, 1, 2}]

f[3]
Out: 6

Integrate[f[x],{x,0,1}]
Out: 2^(n+1)

NIntegrate[f[x],{x,0,1}]
Out:"The integrand If[1+x>0,2^n,0]+If[2+x>0,2^n,0] has evaluated to 
non numerical values for all sampling points in the region with 
boundaries {{0,1}}."

```

For some reason, the sum is performed when doing the integrals, but the dummy variable in the sum is not replaced by the numerical value. Is this a bug? Is there a simple solution to circumvent this for general integrands?

I run Mathematica 11.0.0.0 on Linux (Ubuntu 16.04).