Skip to content

[bug] 函数 badcase #8

@FairyOwO

Description

@FairyOwO

以下代码在测试界面报错

错误: 8:14 keywords: 使用关键字作为变量名 5:10 keywords: 使用关键字作为变量名 2:5 keywords: 使用关键字作为变量名

// 矩阵乘法
func matmul(A, B) {
    result = [];
    i = 0;
    while i < A.len() {
        row = [];
        j = 0;
        while j < B[0].len() {
            sum = 0;
            k = 0;
            while k < A[0].len() {
                sum = sum + A[i][k] * B[k][j];
                k = k + 1;
            }
            row.push(sum);
            j = j + 1;
        }
        result.push(row);
        i = i + 1;
    }
    return result;
}
报错图像

{0866C815-5DC5-46d7-9909-0596C114D8A0}

初步判断为类型问题, func的形参默认类型并非数组(列表), 从而语法检查器发现.len()之后出错

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions