Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`__Generic` cases cannot contains both `enum` and `size_t`

Aperta
#14,122 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sean-mcmanus ci sta già lavorando.

Dal 13/1/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug Language Service

bug

__Generic cases cannot contains both enum and size_t within editor

version

1.29.3

description

console output
expected: foo1
expected: foo2
expected: size_t
workaround1: foo1
workaround1: foo2
workaround1: unkown
workaround2: unknown
workaround2: unknown
workaround2: size_t
vscode problems output
[{
	"resource": "/path/to/reproduce.c",
	"owner": "C/C++: IntelliSense",
	"code": "2534",
	"severity": 8,
	"message": "duplicate association type (\"size_t\" (aka \"unsigned int\")) in _Generic selection",
	"source": "C/C++",
	"startLineNumber": 30,
	"startColumn": 3,
	"endLineNumber": 30,
	"endColumn": 11,
	"origin": "extHost2"
},{
	"resource": "/path/to/reproduce.c",
	"owner": "C/C++: IntelliSense",
	"code": "2534",
	"severity": 8,
	"message": "duplicate association type (\"size_t\" (aka \"unsigned int\")) in _Generic selection",
	"source": "C/C++",
	"startLineNumber": 32,
	"startColumn": 3,
	"endLineNumber": 32,
	"endColumn": 11,
	"origin": "extHost2"
},{
	"resource": "/path/to/reproduce.c",
	"owner": "C/C++: IntelliSense",
	"code": "3227",
	"severity": 8,
	"message": "_Generic construct matches multiple types",
	"source": "C/C++",
	"startLineNumber": 34,
	"startColumn": 3,
	"endLineNumber": 34,
	"endColumn": 11,
	"relatedInformation": [
		{
			"startLineNumber": 34,
			"startColumn": 3,
			"endLineNumber": 34,
			"endColumn": 11,
			"message": "the other match is \"foo1\" (aka \"enum <unnamed>\")",
			"resource": "/path/to/reproduce.c"
		}
	],
	"origin": "extHost2"
},{
	"resource": "/path/to/reproduce.c",
	"owner": "C/C++: IntelliSense",
	"code": "3227",
	"severity": 8,
	"message": "_Generic construct matches multiple types",
	"source": "C/C++",
	"startLineNumber": 39,
	"startColumn": 3,
	"endLineNumber": 39,
	"endColumn": 14,
	"relatedInformation": [
		{
			"startLineNumber": 39,
			"startColumn": 3,
			"endLineNumber": 39,
			"endColumn": 14,
			"message": "the other match is \"foo1\" (aka \"enum <unnamed>\")",
			"resource": "/path/to/reproduce.c"
		}
	],
	"origin": "extHost2"
}]

When expected(X) = GENERIC(enum, size_t)(X)

#define expected(X)                                                            \
  printf("%s: %s\n", "expected",                                               \
         _Generic((X), foo1: "foo1", foo2: "foo2", size_t: "size_t"))
  • expected(enum) is OK in terminal, ERR in vscode
  • expected(size_t) is OK in terminal, ERR in vscode

When workaround1(X) = GENERIC(enum, default)(X)

  • workaround1(enum) is OK in terminal, OK in vscode
  • workaround1(size_t) is unknown in terminal, ERR in vscode

When workaround2(X) = GENERIC(size_t, default)(X)

  • workaround2(enum) is unknown in terminal, OK in vscode
  • workaround2(size_t) is OK in terminal, OK in vscode

reproduce

code

/path/to/reproduce.c

#include <stddef.h>
#include <stdio.h>

#define expected(X)                                                            \
  printf("%s: %s\n", "expected",                                               \
         _Generic((X), foo1: "foo1", foo2: "foo2", size_t: "size_t"))

#define workaround1(X)                                                         \
  printf("%s: %s\n", "workaround1",                                            \
         _Generic((X), foo1: "foo1", foo2: "foo2", default: "unkown"))

#define workaround2(X)                                                         \
  printf("%s: %s\n", "workaround2",                                            \
         _Generic((X), size_t: "size_t", default: "unknown"))

typedef enum {
  foo1_default,
} foo1;

typedef enum {
  foo2_default,
} foo2;

int main() {
  foo1 value_foo1 = foo1_default;
  foo2 value_foo2 = foo2_default;
  size_t value_size_t = 0;

  // editor error
  expected(value_foo1);
  // editor error
  expected(value_foo2);
  // editor error
  expected(value_size_t);

  workaround1(value_foo1);
  workaround1(value_foo2);
  // editor error
  workaround1(value_size_t);

  workaround2(value_foo1);
  workaround2(value_foo2);
  workaround2(value_size_t);

  return 0;
}
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
20h 38m
PR unite (30g)
49

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/vscode-cpptools

Tutte le issue di microsoft/vscode-cpptools

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.