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

system.insert wipes the string if item is an empty string #23223

Closed
ghost opened this issue Jan 17, 2024 · 1 comment · Fixed by #23225
Closed

system.insert wipes the string if item is an empty string #23223

ghost opened this issue Jan 17, 2024 · 1 comment · Fixed by #23225

Comments

@ghost
Copy link

ghost commented Jan 17, 2024

Description

This code currently works with --mm:refc, but with --mm:arc or ORC (default) it replaces all characters in the string with null bytes:

proc main = 
  var stuff = "hello"
  stuff.insert ""
  echo repr stuff
  echo stuff.len

main()

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-01-17
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: f46f26e79aada7195f4d83d8601f0d856520763d
active boot switches: -d:release

Current Output

"\0\0\0\0\0"
5

Expected Output

Either a runtime error when calling insert with an empty item, or fixing the bug so that the output becomes:

"hello"
5

Possible Solution

No response

Additional Information

No response

@ringabout ringabout self-assigned this Jan 18, 2024
@ringabout
Copy link
Member

Yeah, it needs to prevent self movement.

Araq pushed a commit that referenced this issue Jan 18, 2024
narimiran pushed a commit that referenced this issue Apr 19, 2024
narimiran pushed a commit that referenced this issue Apr 19, 2024
narimiran pushed a commit that referenced this issue Apr 20, 2024
narimiran pushed a commit that referenced this issue Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant