Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tknawara opened this issue Apr 8, 2025 · 0 comments

Comments

@tknawara
Copy link

tknawara commented Apr 8, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant