As I understand it, when comparing the "returns" of paying off my student loan debt to expected returns on investing, I should be using either the nominal rate or CAGR—not the real rate of return—of investing, since inflation would be impacting both the same way. Is that correct?
Debt is nominal, which means when inflation happens, the value of the money owed goes down. This is great for the borrower and bad for the lender.
"Investing" can mean a lot of different things. Frequently it is used to describe buying common stock, which is an ownership claim on a company. A company is not a nominally fixed asset, by which I mean if there was a bunch of inflation and nothing else happened (i.e., the inflation was not the cause or result of some other economic change) then the nominal value of the company will go up along with the prices of other things.
Based on the above, I'd say you are incorrect to treat debt and investment returns the same way with respect to inflation. When we say equity returns 9%, we mean it returns a real 7% plus 2% inflation or whatever. If the rate of inflation increased to 10% and nothing else happened in the economy, the same equity would be expected to return 17%. In fact, the company's (nominally fixed) debts would be worth less, increasing the real value of the company at the expense of their debt-holders. On the other hand, if we entered a period of high inflation, your debt liability would go way down and you would have benefited greatly from borrowing and investing at the same time.
If you are expecting inflation in the abstract sense, then borrowing and investing in common stock is a great idea.
Inflation is frequently the result (or cause) of a period of economic trouble, so please be aware that the above makes sense if we treat inflation as the only thing that changed. If inflation came about because OPEC makes oil crazy expensive, millennials just stop working, all of our factories got bombed to hades, or trade wars have shut down international commerce, then the value of stocks would most definitely be affected. In that case it's not really "inflation" that affected the stock returns, though.
I'd agree, inflation affects the value of the dollar you measure anything in. So, it makes your debt fade away at the same rate it eats away at dollar denominated assets. I'd suggest that one should also look at the tax effect of the debt or assets as well.
For example, my 3.5% mortgage costs me 2.625% after tax. But a 4% long term cap gain in stocks, costs me .6% in tax for a net 3.4%.