Skip to content

vscode dscanner - struct initializer with named argument confuses DScanner #966

Description

@tknawara

Hi,

I've been using D in vscode with code-d extension, now I have an assoc array that I'm trying to initialize where the values are a struct.

Using named arguments in the struct shows so many errors in vscode, (and formatting also seems to be confused) while dmd compiles the code just fine, this is a screenshot.

Image

and full code snippet

struct OperandConstraint
{
    OperandKind[] allowedKind;
}

struct InstructionSemaInfo
{
    size_t operandCount;
    bool allowMemoryToMemory;
    bool allowImmAsOperand;
    bool srcMustBeMemory;
    OperandConstraint[] operandConstraints;
    string[] notes;
}

InstructionSemaInfo info = {operandCount: 2};

immutable InstructionSemaInfo[Mnemonic] instructionSemaTable = [
    Mnemonic.mov: InstructionSemaInfo(
    operandCount : 2,
    allowMemoryToMemory:
        false,
    allowImmAsOperand:
        true,
    srcMustBeMemory:
        false,
    operandConstraints:
        [
            OperandConstraint([OperandKind.register, OperandKind.memory]),
            OperandConstraint([
                    OperandKind.register, OperandKind.memory, OperandKind.imm
                ]),
        ],
    notes:
        []
    ),
];

Compiling this with dmd just works

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions