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

Yojson 2.1.1 errors can have have incorrect locations #171

Closed
johnridesabike opened this issue Oct 22, 2023 · 4 comments
Closed

Yojson 2.1.1 errors can have have incorrect locations #171

johnridesabike opened this issue Oct 22, 2023 · 4 comments
Labels

Comments

@johnridesabike
Copy link

Example:

let () =
  try ignore @@ Yojson.Basic.from_string {|{"badjson": error}|}
  with Yojson.Json_error s -> print_endline s

Output with 2.1.0:

Line 1, bytes 12-18:
Invalid token 'error}'

Output with 2.1.1:

Line 1, bytes 17-18:
Invalid token 'error}'
@ElectreAAS
Copy link
Contributor

Same problem here (example in utop)
With 2.1.0:

# Yojson.Safe.from_string "hello";;
Exception: Yojson.Json_error "Line 1, bytes 0-5:\nInvalid token 'hello'".

With 2.1.1:

# Yojson.Safe.from_string "hello";;
Exception:
Yojson__Common.Json_error "Line 1, bytes 4-5:\nInvalid token 'hello'".

@Leonidas-from-XIV
Copy link
Member

Thanks, that's indeed a regression. Would one of you want to submit a test for it?

The only relevant change I can think of is #168, will need to be looked into.

@ElectreAAS
Copy link
Contributor

Would one of you want to submit a test for it?

On it

@Leonidas-from-XIV
Copy link
Member

Fixed in #172.

Leonidas-from-XIV added a commit to Leonidas-from-XIV/opam-repository that referenced this issue Nov 23, 2023
CHANGES:

*2023-11-23*

### Fixed

- Fix the error location reported in the exception. Regression in 2.1.1
  (reported by @johnridesabike, regression test by @ElectreAAS, fix by
  @Leonidas-from-XIV, ocaml-community/yojson#171, ocaml-community/yojson#172)
nberth pushed a commit to nberth/opam-repository that referenced this issue Jun 18, 2024
CHANGES:

*2023-11-23*

### Fixed

- Fix the error location reported in the exception. Regression in 2.1.1
  (reported by @johnridesabike, regression test by @ElectreAAS, fix by
  @Leonidas-from-XIV, ocaml-community/yojson#171, ocaml-community/yojson#172)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants