| All you're doing is passing an argument of the incorrect type to your function. The exact same thing fails to compile in C: ```
#include <stdio.h> typedef struct {
int value;
} Feet; typedef struct {
int value;
} Meters; void hover(Meters altitude) {
printf("At %i meters\n", altitude.value);
} int main() {
Meters altitude1 = {.value = 16};
hover(altitude1);
Feet altitude2 = {.value = 16};
hover(altitude2);
}
``` ```
error: passing 'Feet' to parameter of incompatible type 'Meters'
20 | hover(altitude2);
``` Coming from a dynamically typed language (Python, etc), this might seem like a revelation, but its old news since the dawn of programming computers. A C language server will pick this up before compile time, just like `rust-analyzer` does: `argument of type "Feet" is incompatible with parameter of type "Meters"`. Did you not know this? I feel like a lot of people on message boards criticizing C don't know that this would fail to compile and the IDE would tell you in advance... |