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

fix(compiler): Incorrect focus on error [LNG-274] #959

Merged
merged 9 commits into from
Nov 2, 2023

Conversation

DieMyst
Copy link
Member

@DieMyst DieMyst commented Nov 2, 2023

Description

func arr(strs: []string) -> []string
  <- strs

this code throws StringOutOfBound instead of parser error

Proposed Changes

Pad strings that the compiler error renderer can point.

Checklist

  • Corresponding issue has been created and linked in PR title.
  • Proposed changes are covered by tests.
  • Documentation has been updated to reflect the changes (if applicable).
  • I have self-reviewed my code and ensured its quality.
  • I have added/updated necessary comments to aid understanding.

Reviewer Checklist

  • Tests have been reviewed and are sufficient to validate the changes.
  • Documentation has been reviewed and is up to date.
  • Any questions or concerns have been addressed.

Copy link

linear bot commented Nov 2, 2023

LNG-274 StringIndexOutOfBoundsException on correct code

func arr(strs: []string) -> []string
  <- strs

func test() -> i8:
  a = ["12", "34"]
  arr(a)
  <- 2

throws

[error] java.lang.StringIndexOutOfBoundsException: String index out of range: 37
…

@DieMyst
Copy link
Member Author

DieMyst commented Nov 2, 2023

also fixes LNG-272

@DieMyst DieMyst added the e2e Run e2e workflow label Nov 2, 2023
@DieMyst DieMyst enabled auto-merge (squash) November 2, 2023 06:55
Co-authored-by: InversionSpaces <InversionSpaces@vivaldi.net>
Comment on lines 54 to 64
): FocusedLine =
val end = idx + len
// if we want to point to the place after a string, pad this string with spaces
val padded =
if (str.length < idx + len) str.padTo(end, ' ')
else str
FocusedLine(
padded.substring(0, idx),
padded.substring(idx, end),
padded.substring(end)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use String#slice method?

DieMyst and others added 3 commits November 2, 2023 14:26
Co-authored-by: InversionSpaces <InversionSpaces@vivaldi.net>
Co-authored-by: InversionSpaces <InversionSpaces@vivaldi.net>
str.substring(idx + len)
)
): FocusedLine =
val end = idx + len
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could you wrap the method in {}?
I don't like indentation as scope marking

Copy link
Member Author

Choose a reason for hiding this comment

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

me too

DieMyst and others added 3 commits November 2, 2023 15:12
Co-authored-by: InversionSpaces <InversionSpaces@vivaldi.net>
Co-authored-by: InversionSpaces <InversionSpaces@vivaldi.net>
@DieMyst DieMyst merged commit 6e6b567 into main Nov 2, 2023
10 checks passed
@DieMyst DieMyst deleted the LNG-274-incorrect-focus-on-error branch November 2, 2023 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants