Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate code for Struct/Data hash/== #110

Conversation

segiddins
Copy link
Contributor

No description provided.

Signed-off-by: Samuel Giddins <segiddins@segiddins.me>
@segiddins segiddins force-pushed the segiddins/generate-code-for-struct-data-hash branch from c26d51a to e29a996 Compare October 16, 2024 18:18
@joeldrapper joeldrapper merged commit 24399d6 into joeldrapper:main Oct 16, 2024
0 of 2 checks passed
@stevegeek
Copy link
Collaborator

Since updating literal I think Im seeing a problem with equality of Structs

class Person < Literal::Struct
	prop :name, String
end

class Student < Person
	prop :final_grade, Integer
end

test do
	a = Person.new(name: "Joel")
	b = Student.new(name: "Joel", final_grade: 90)

	expect(a) != b
end

gives

expected #<#<Class:0x000000011f1bed90>::Person:0x000000011f0d6860 @name="Joel"> to != #<#<Class:0x000000011f1bed90>::Student:0x000000011f0d67e8 @name="Joel", @final_grade=90>

It seems the new implementation assumes equality if the other struct has the same attributes + values but doesnt account for if the other struct has other attributes that are not on the current

@stevegeek
Copy link
Collaborator

Pushed a failing test to main so we can then resolve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants