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

Bump Prism to v0.30.0 #215

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions parser/prism/Translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,11 @@ std::unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
auto *rationalNode = reinterpret_cast<pm_rational_node *>(node);
pm_location_t *loc = &rationalNode->base.location;

const uint8_t *start = rationalNode->numeric->location.start;
const uint8_t *end = rationalNode->numeric->location.end;
const uint8_t *start = loc->start;
const uint8_t *end = loc->end;

std::string value = std::string(reinterpret_cast<const char *>(start), end - start);
// TODO: drop one char to remove the "r" at the end of the value
auto value = std::string_view(reinterpret_cast<const char *>(start), end - start - 1);

return make_unique<parser::Rational>(parser.translateLocation(loc), value);
}
Expand Down Expand Up @@ -634,6 +635,7 @@ std::unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE:
case PM_INTERPOLATED_SYMBOL_NODE:
case PM_INTERPOLATED_X_STRING_NODE:
case PM_IT_LOCAL_VARIABLE_READ_NODE:
case PM_IT_PARAMETERS_NODE:
case PM_LAMBDA_NODE:
case PM_LOCAL_VARIABLE_AND_WRITE_NODE:
Expand Down
11 changes: 9 additions & 2 deletions test/prism_regression/rational.parse-tree.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Rational {
val = "42.0"
Begin {
stmts = [
Rational {
val = "42.0"
}
Rational {
val = "42.00000"
}
]
}
5 changes: 5 additions & 0 deletions test/prism_regression/rational.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# typed: true

42.0r

42.00000r

# Rationals containing "/" are not considered rational literals
# e.g. 2/3r is actually int 2 divided by 3 rational (3r is a rational, not the whole thing)
6 changes: 3 additions & 3 deletions third_party/externals.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def register_sorbet_dependencies():

http_archive(
name = "prism",
url = "https://github.com/ruby/prism/archive/v0.29.0.zip",
sha256 = "b932567314deb898fe9deddf7839b7e2089b54087c24d74aa193515b3eb69d2f",
strip_prefix = "prism-0.29.0",
url = "https://github.com/ruby/prism/archive/v0.30.0.zip",
sha256 = "df9f36fae6ccce96cce3f5bbe7b4b8e8a0dd597feb02a9c5d21224007cf47138",
strip_prefix = "prism-0.30.0",
build_file = "@com_stripe_ruby_typer//third_party:prism.BUILD",
)

Expand Down