Improve error reporting for the import keyword

fixes #8061