Skip to content

Commit

Permalink
Merge pull request #215 from Shopify/emily/prism-0.30.0
Browse files Browse the repository at this point in the history
Bump Prism to v0.30.0
  • Loading branch information
egiurleo authored Aug 23, 2024
2 parents 12e07c9 + bb55e4a commit b4d6556
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
8 changes: 5 additions & 3 deletions parser/prism/Translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,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 @@ -651,6 +652,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

0 comments on commit b4d6556

Please sign in to comment.