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

Support Record Expression #74

Merged
merged 9 commits into from
Feb 28, 2019
Merged

Conversation

yoshihiro503
Copy link
Contributor

for #54

Support following expressions.

  • record creation: #user{name = "Taro", admin = true}
  • record field access: U#user.name
  • record field index number: #user.name
  • record update: U#user{admin = true}

begin match record_field_of_sf sf with
| Ok (RecordField {line; field_name; ty=None; default_expr=Some e}) ->
(line, field_name, e) |> return
| Ok _ -> failwith "cannot reach here"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you use Err.Invalid_input?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

begin match record_field_of_sf sf with
| Ok (RecordField {line; field_name; ty=None; default_expr=Some e}) ->
(line, field_name, e) |> return
| Ok _ -> failwith "cannot reach here"
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

Copy link
Collaborator

@amutake amutake left a comment

Choose a reason for hiding this comment

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

Sorry, one more.

| Error e -> Error e
end
in
let%bind expr = sf_expr |> expr_of_sf in
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add |> track ~loc:[%here]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks

| Ok (RecordField {line; field_name; ty=None; default_expr=Some e}) ->
(line, field_name, e) |> return
| Ok _ ->
Err.create ~loc:[%here] (Err.Invalid_input ("cannot reach here", sf)) |> Result.fail
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you make error message more detailed? e.g., "record field must have field name and expression" 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see 🙏

| Ok (RecordField {line; field_name; ty=None; default_expr=Some e}) ->
(line, field_name, e) |> return
| Ok _ ->
Err.create ~loc:[%here] (Err.Invalid_input ("cannot reach here", sf)) |> Result.fail
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see 🙏

Copy link
Collaborator

@amutake amutake left a comment

Choose a reason for hiding this comment

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

LGTM

@amutake amutake merged commit b4a46aa into yutopp:master Feb 28, 2019
@yoshihiro503 yoshihiro503 deleted the record_expr branch March 1, 2019 06:28
@yutopp yutopp added this to the 0.1.4 milestone Mar 1, 2019
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.

3 participants