code
https://pastebin.pl/view/a021251b
question
I need to explain this errors while trying to fix it but I can't and I'm so tired I've been trying to fix this for 7 hours.
1 - expression '' has no type (or is ambiguous) 2 - undeclared field: 'y' 3 - type mismatch
question
4 - Expression: += astro.speed [1] : [2] astro.speed: Expected one of (first mismatch at [position]): [1] proc +=[T: SomeInteger](x: var T; y: T) [1] proc +=[T: float | float32 | float64](x: var T; y: T) [1] template +=[T: Vector2 | Vector3 | Quaternion | Matrix](v1: var T; v2: T) [1] template +=[T: Vector2 | Vector3 | Quaternion](v1: var T; value: cfloat)
question
5 - expression 'astro' has no type (or is ambiguous)
thamls good people
i search in google what this erros mean but still i can't fix i change but i don't know
i search my problems but still i can't fix and i comes here i start learn nim today
I don't know how did you end up with this code, but it's plagued with errors.
"Has no type...", then give it a type.
You construct the Object without reading the manual. At L46 you have:
But the manual shows this:
Change the construction at L46 to:
This leads us to "type mismatch:", as
astro_texture
is anImage
, and not aTexture2D
as expected byAstroObject
:Now we have another "type mismatch: got 'int' for 'astroSpeed' but expected 'float'". Just cast:
Now we got: "Error: undeclared identifier: 'astro'" at L82, turns out a
if astro in astros
really meansfor astro in astros
.This hurts: "Error: undeclared identifier: 'astrp'" at L83.
Now "Error: type mismatch" at L83. Why do you cast
astro.speed
to a float, when it's already a float and astro.y expects an int? Change the line to:Finally, we arrive at a proper error that could puzzle anyone:
Why the compiler claims that two ints are not ints? Turns out
astro.y
is inmutable, but you want to mutate it (i.e. the compiler wantsastro.y
to be avar int
). Go change the Object to a Mutable or Ref Object:Back to incomprehensible errors: "Error: undeclared identifier: 'random'". You don't call
random
, you callrand
:(Notice the casting to float).
There you go. Assuming you have all the needed libraries, it should work. Next time, you should try to introduce code step by step, and making each of them work properly, before adding lots of code and then having dozens of errors, typos and lack of types all around.