Skip to content

Conversation

@Maxlytrius
Copy link
Contributor

Builtin functions to assert lrc/sbrc

Copy link
Collaborator

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decent overall, please also check the CI

});
}

void assert_rc__function_impl(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void assert_rc__function_impl(
void assert_rc_function_impl(

}
// Remove string object whitespace
auto s = count_str->get_name();
if (s[0] == '\"')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be undefined behaviour, if the string is empty


void test_builtins()
{
// Onus is on caller to provide a string object representing an actual integer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Onus?

expected = "2"
assert_lrc(r1, expected)
# Using string directly
assert_lrc(r1, "2") No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_lrc(r1, "2")
assert_lrc(r1, "2")

Some in the other files

@@ -0,0 +1,3 @@
# Not a string
a = {}
assert_lrc(a, a) No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument should be a bridge

auto count_str = frame->stack_pop("count_str");
auto bridge = frame->stack_pop("bridge");
// Make sure we're comparing the correct LRC value
rt::remove_reference(frame->object(), bridge);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can cause undefined behaviour of the RC hits 0.

@xFrednet xFrednet closed this Sep 26, 2025
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