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

chained methods do no parse correctly if . is separated from call #23258

Open
2 tasks
sredrv opened this issue Dec 24, 2024 · 2 comments
Open
2 tasks

chained methods do no parse correctly if . is separated from call #23258

sredrv opened this issue Dec 24, 2024 · 2 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@sredrv
Copy link

sredrv commented Dec 24, 2024

Describe the feature

V currently supports, method chaining in single-line, as below.

	mut s:= 'aAabBc'
	s = s.camel_to_snake().to_lower().to_upper()

I want V to support, methods specified on more than one line:

	mut s:= 'aAabBc'
	s = s.  camel_to_snake().
                 to_lower().
                 to_upper()

Use Case

Readability issue, when more custom built methods are used.

Proposed Solution

V language parser needs to be enhanced

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.9

Environment details (OS name and version, etc.)

OS Linux

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@felipensp felipensp added the Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one. label Dec 24, 2024
@JalonSolov
Copy link
Contributor

JalonSolov commented Dec 24, 2024

The code works as expected if you move the .s to the front of each call (no spaces between), as in

        mut s:= 'aAabBc'
        s = s   .camel_to_snake()
                .to_lower()
                .to_upper()
        println(s)

which gives the output

A_AAB_BC

Now, whether or not it should be considered an error with the . at the end, I don't know.

@JalonSolov JalonSolov removed the Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one. label Dec 24, 2024
@JalonSolov JalonSolov changed the title parse multi-line chainable methods chained methods do no parse correctly if . is separated from call Dec 24, 2024
@JalonSolov JalonSolov added the Bug This tag is applied to issues which reports bugs. label Dec 24, 2024
@JalonSolov
Copy link
Contributor

At the very least, the error messages could be cleaned up a LOT, to better convey what's wrong. Here's what you get currently:

x.v:2:10: error: `string` has no property ``
    1 |     mut s:= 'aAabBc'
    2 |     s = s.  camel_to_snake().
      |             ~~~~~~~~~~~~~~~~~
    3 |                  to_lower().
    4 |                  to_upper()
x.v:2:4: error: assignment mismatch: 1 variable 0 values
    1 |     mut s:= 'aAabBc'
    2 |     s = s.  camel_to_snake().
      |       ^
    3 |                  to_lower().
    4 |                  to_upper()
x.v:3:18: error: unknown function: to_lower
    1 |     mut s:= 'aAabBc'
    2 |     s = s.  camel_to_snake().
    3 |                  to_lower().
      |                  ~~~~~~~~~~
    4 |                  to_upper()
x.v:3:18: error: `to_lower()` does not return a value
    1 |     mut s:= 'aAabBc'
    2 |     s = s.  camel_to_snake().
    3 |                  to_lower().
      |                  ~~~~~~~~~~~
    4 |                  to_upper()
x.v:4:18: error: unknown function: to_upper
    2 |     s = s.  camel_to_snake().
    3 |                  to_lower().
    4 |                  to_upper()
      |                  ~~~~~~~~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

3 participants