MajeedKazemi / code-struct

A new text-based environment that helps beginners transition into conventional text-based programming environments.
http://code-struct.vercel.app
GNU General Public License v3.0
26 stars 10 forks source link

on-insert-into for addition: should consider updating possible types when left and right types change #530

Closed MajeedKazemi closed 2 years ago

MajeedKazemi commented 2 years ago

image image image image

vicchig commented 2 years ago

They are updated, but I think some code constructs use different insertion paths so the update just does not run for all of them. I will take a look and see what exactly is wrong.

MajeedKazemi commented 2 years ago

image

inserted x = input("asdf") and then print((x + 123)) the 123 was highlighted at first. then when I inserted the int() around the input, it is suggesting that both of them should be converted to str. I think we've had a great progress by showing both warnings. but maybe in this particular case, it should just not show any warning :)

I don't even know if you were trying to fix this in your pull request #558

vicchig commented 2 years ago

I am not sure how you are getting the warning on the x to appear. If I follow these exact steps only the 123 remains highlighted. It of course should not be highlighted once you insert the int cast. I will add that.

vicchig commented 2 years ago

Never mind I see. You are inserting the addition using x+ instead of + followed by adding the x in so it is not updating the types properly because that insertion path probably does not call the update function.

replaceWithBinaryOp did not get the updates to the type checking so this is why this happens.