aardappel / lobster

The Lobster Programming Language
http://strlen.com/lobster
2.24k stars 121 forks source link

Only right multiplying float vectors by numerics is allowed #245

Closed franklinscudder closed 1 year ago

franklinscudder commented 1 year ago

Version

Using the prebuilt windows binaries, v2023.4

Summary

Attempting to left multiply a float vector by an integer or float will raise an error however right multiplication is allowed.

If this is intended behaviour perhaps it could be mentioned in the docs?

Example

The following code can be used to reproduce the errors described.

import vec

let v = xyz_1

print(v * 3.0)
// prints -> xyz_f{3.0, 3.0, 3.0}

print(v * 3)
// prints -> xyz_f{3.0, 3.0, 3.0}

print(3.0 * v)
// error: can't use `*` on `float` and `xyz_f`

print(3 * v)
// error: can't use `*` on `int` and `xyz_f`
aardappel commented 1 year ago

Not sure how you're getting this, since support for this was implemented long ago, way before 2023.4 If I run your code it works:

t.lobster(8): warning: integer literal (3) where float expected
t.lobster(14): warning: integer literal (3) where float expected
xyz_f{3.0, 3.0, 3.0}
xyz_f{3.0, 3.0, 3.0}
xyz_f{3.0, 3.0, 3.0}
xyz_f{3.0, 3.0, 3.0}
franklinscudder commented 1 year ago

Apologies, I checked my config and vscode was using an old binary, I see it works now.