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

(many) Support more types in string+int and int+string concatenation #473

Merged
merged 2 commits into from
May 7, 2024

Conversation

perlun
Copy link
Collaborator

@perlun perlun commented May 7, 2024

No description provided.

@perlun perlun added this to the 0.5.0 milestone May 7, 2024
@perlun perlun added stdlib Things related to the Perlang API/stdlib experimental compilation Issues which are relevant when using experimental compilation labels May 7, 2024
rightTypeReference.ClrType == typeof(AsciiString))) {
// 42 + "string" + 42
expr.TypeReference.ClrType = typeof(AsciiString);
}
else if (expr.Operator.Type == TokenType.PLUS &&
(leftTypeReference.ClrType == typeof(int) &&
(new[] { typeof(int), typeof(long), typeof(uint), typeof(ulong) }.Contains(typeof(int)) &&
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, these three are quite obviously wrong. 😁 Let's see if we have a test that covers this error of mine... 🙈

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we do, in fact. The [Internal compiler error](error: no viable conversion from 'shared_ptr)` problem is probably caused by this, triggering a different code path, making a previously skipped test no longer be skipped... and that test in turn is currently broken, since it generates C++ code which looks like this:

std::shared_ptr<const perlang::ASCIIString> a = perlang::ASCIIString::from_static_string("a");
perlang::print(a);
std::shared_ptr<const perlang::ASCIIString> b = (*a + *perlang::ASCIIString::from_static_string(" b"));
perlang::print(b);
std::shared_ptr<const perlang::ASCIIString> c = (*a + *perlang::ASCIIString::from_static_string(" c"));
perlang::print(c);
std::shared_ptr<const perlang::ASCIIString> d = (*b + *perlang::ASCIIString::from_static_string(" d"));
perlang::print(d);

This fails because some of these + operators return a std::shared_ptr<const perlang::String>, which can't be converted to std::shared_ptr<const perlang::ASCIIString>. We'll have to look into this at some point, but not tonight...

@perlun perlun force-pushed the feature/string-and-unsigned-int-concatenation branch from 48e684d to ac29a54 Compare May 7, 2024 19:46
@perlun perlun force-pushed the feature/string-and-unsigned-int-concatenation branch from ac29a54 to c63fda4 Compare May 7, 2024 20:17
@perlun perlun enabled auto-merge (squash) May 7, 2024 20:17
...and remove some commented out code that was merged by mistake
in #462.
@perlun perlun force-pushed the feature/string-and-unsigned-int-concatenation branch from c63fda4 to 321f94d Compare May 7, 2024 20:24
@perlun perlun merged commit a9fe3b8 into master May 7, 2024
11 checks passed
@perlun perlun deleted the feature/string-and-unsigned-int-concatenation branch May 7, 2024 20:27
@perlun perlun mentioned this pull request May 8, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental compilation Issues which are relevant when using experimental compilation stdlib Things related to the Perlang API/stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant