Bug 描述
当声明一个返回类型的函数时,编译器允许我返回一个类型的对象而不会出错。StaticTuple[X, ElmType]ElmType
重现步骤
有问题的代码:
from utils.index import StaticTuple
from tensor import Tensor
alias Scalar = DType.float64
fn fetch_data() raises -> StaticTuple[4, Tensor[Scalar]]:
return Tensor[Scalar]()
let data = fetch_data()
print(data.__len__())
输出: 4
我希望编译器不允许我编写此代码。
- What OS did you do install Mojo on ?
Darwin 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103 arm64
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 0.5.0 (6e50a738)
- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.2.2 (95d42445)