Skip to content

A value of type X cannot be used to initialize an entity of type X #3212

Description

@Leedehai

Type: LanguageService

Describe the bug

  • OS and Version: macOS 10.14.3
  • VS Code Version: 1.13.1
  • C/C++ Extension Version: 0.21.0
  • Other extensions you installed (and if the issue persists after disabling them): too many... yes
  • A clear and concise description of what the bug is: A value of type X cannot be used to initialize an entity of type X

To Reproduce

  1. Create a new document, select the language to be "C++", and type:
struct Value {
    struct Array;
    struct Dict;
    struct Primitive;

    Value() {}
    virtual ~Value() {}

    virtual Array * asArray() { assert(false); }
    virtual Dict * asDict() { assert(false); }
    virtual Primitive * asPrimitive() { assert(false); }

    int asInt();
    double asDouble();
    std::string asDate();
    std::string asString();
};

struct Value::Array : public Value {

    Array() {}
    ~Array() {}

    Value::Array * asArray() { 
        Value::Array * result = this; 
        return result;
    }
};
  1. Wait for the IntelliSence's error squiggle and message (shown in screenshot).

Expected behavior

This is a legitimate assignment and there should not be an error.

Screenshots
screen shot 2019-02-24 at 23 38 36

other info:
Might related to this on StackOverflow, though it's not clear whether the problem described in that post occurred in VSCode or other IDE/editor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceVisual StudioInherited from Visual StudiobugfixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions