Skip to content

using continue in expression produces wrong result in js backend #22239

@hamidb80

Description

@hamidb80

Description

func number(lit: string): string =
  for b in lit:
    result.add:
      if b in '0'..'9': b
      elif b == '_': continue
      else: raise newException(ValueError, "not a valid digit")

let s = number "1_2_3"
echo s, " ", s.len

Nim Version

Nim Compiler Version 1.6.14 [Windows: amd64]
Compiled at 2023-06-27
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release

Current Output

JS backend:

11223 5

Expected Output

like C backend:

123 3

Additional Info

same with case

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions