8000 Feature/1001 avoid segfault on empty literal mergestring by pocket7878 · Pull Request #1012 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature/1001 avoid segfault on empty literal mergestring #1012

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

Merged
merged 5 commits into from
Jun 24, 2019
Merged

Feature/1001 avoid segfault on empty literal mergestring #1012

merged 5 commits into from
Jun 24, 2019

Conversation

pocket7878
Copy link
Contributor

Motivation

close #1001

Test plan

See included automated tests.

@pocket7878 pocket7878 requested a review from a team June 23, 2019 08:30
@ghost ghost requested review from DarkDimius and removed request for a team June 23, 2019 08:30
@DarkDimius
Copy link
Collaborator

Thank you for great contribution and great testcase!

@@ -94,7 +94,10 @@ unique_ptr<Expression> mergeStrings(DesugarContext dctx, core::Loc loc,
loc,
dctx.ctx.state.enterNameUTF8(fmt::format(
"{}", fmt::map_join(stringsAccumulated.begin(), stringsAccumulated.end(), "", [&](const auto &expr) {
return cast_tree<Literal>(expr.get())->asString(dctx.ctx).data(dctx.ctx)->shortName(dctx.ctx);
if (isa_tree<EmptyTree>(expr.get()))
return std::basic_string_view("");
Copy link
Collaborator

Choose a reason for hiding this comment

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

""sv will make it more readable.

Copy link
Collaborator
@DarkDimius DarkDimius left a comment

Choose a reason for hiding this comment

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

Super minor nitpick, otherwise LGTM

jez
jez previously requested changes Jun 23, 2019
Copy link
Collaborator
@jez jez left a comment

Choose a reason for hiding this comment

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

lgtm pending the two comments

auto ast = sorbet::parser::Parser::run(gs, "<test>", "\"#{}:\"");
sorbet::core::MutableContext ctx(gs, sorbet::core::Symbols::root());
auto o1 = sorbet::ast::desugar::node2Tree(ctx, move(ast));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test case is redundant with the test/testdata test, and the other one is shorter and easier to grep for.

Do you mind deleting this?

@pocket7878
Copy link
Contributor Author

@DarkDimius @jez
Thank you for your reviews!
I just updated my code!

@DarkDimius
Copy link
Collaborator

Thank you! Kicking off CI, will merge when it passes!
Thank you so much!

@DarkDimius DarkDimius merged commit 84ca94b into sorbet:master Jun 24, 2019
@pocket7878 pocket7878 deleted the feature/1001-avoid-segfault-on-empty-literal-mergestring branch June 24, 2019 03:04
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.

Segmentation Fault on "#{}:"
3 participants
0