Skip to content

Commit

Permalink
remove extra into() and cover xo_functionColor
Browse files Browse the repository at this point in the history
  • Loading branch information
ouz-a committed Oct 27, 2023
1 parent 95c69e5 commit 1dd95c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pax-compiler/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ fn recurse_pratt_parse_to_string<'a>(
let mut pairs = primary.clone().into_inner();
let mut output = "".to_string();
let mut next_pair = pairs.next().unwrap();
let mut add_into = false;
// This helps us transform `Color` into `Fill` in the cases of `{Color::rgb(...)}`
if next_pair.as_str() == "Color" {
add_into = true;
}
match next_pair.as_rule() {
Rule::literal_color => {
return recurse_pratt_parse_to_string(primary.into_inner(), pratt_parser, Rc::clone(&symbolic_ids));
Expand All @@ -137,6 +142,9 @@ fn recurse_pratt_parse_to_string<'a>(
output = output + "(" + &recurse_pratt_parse_to_string(next_pair.into_inner(), pratt_parser, Rc::clone(&symbolic_ids)) + "),"
}
output = output + ")";
if add_into {
output = output + ".into()"
}

output
},
Expand Down
2 changes: 1 addition & 1 deletion pax-compiler/templates/cartridge-lib.tera
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn instantiate_expression_table<R: 'static + RenderContext>() -> HashMap<usi
{% endif %}

TypesCoproduct::{{ expression_spec.pascalized_return_type }}(
{{ expression_spec.output_statement }}.into()
{{ expression_spec.output_statement }}
)
}));
{% endfor %}
Expand Down

0 comments on commit 1dd95c4

Please sign in to comment.