Mojo docs example possibly out of date

Maybe this fits here - I’m not really sure. I did post on the Discord as well.

System requirements | Mojo has a check_gpu.mojo file that looks like this:

from gpu.host import DeviceContext

def main():
    var ctx = DeviceContext()
    print("GPU:", ctx.name())

However, that didn’t compile for me. The errors were clear enough and I got it working with:

from std.gpu.host import DeviceContext

def main():
    try:
        var ctx = DeviceContext()
        print("GPU:", ctx.name())
    except e:

I presume the web page is out of date with the language? If so, should this be reported somewhere (or just here) or is it worth submitting a PR with a change? (Not necessarily this specific code, but similar with the exception message perhaps; I presume there are some best practices for any examples.)

Hey Daren, this looks like the same issue as your other thread, which is the need to fully qualify standard library imports with std. prefix

The fix for these just merged so expect it the docs pages to be updated in the nightly release. Thanks again for raising these.

Thanks.

Yes, I posted the other thread because it wasn’t about the docs as such, but the error message itself not as being helpful in the newer build. I appreciate they amount to two aspects of the same issue.

True, there’s an opportunity to improve the error message there (for developers using older example code). I’ll raise that for follow-up.