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

In-Game: string() and show_debug_message() should add support for {{ and }} to escape the brace characters #8564

Closed
gm-bug-reporter bot opened this issue Nov 29, 2024 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation are required by this issue feature request New feature (or a request for one)
Milestone

Comments

@gm-bug-reporter
Copy link

Description

When string is applied at the runtime, all numbers between curly braces are replaced with corresponding arguments (unless no corresponding argument is found, then they're passed as-is). There seems to be no special behaviour that would allow escaping the braces by doubling them like in C#.

However, if a string call is resolvable at compile time, the double curly braces are treated as non-placeholder single braces, the way C# runs its string.Format.

Whether the intended behaviour is to allow escaping double curly braces or just replacing patterns as-is, this is an inconsistency between equivalent runtime and compile time behaviours. I don't mind either way (although I prefer having an option to escape than not), as long as runtime and compiler agree.

Steps To Reproduce

Create an empty project and a script with a following code:

var _zero = "zero";
var _one = "one";

show_debug_message(string("This is some {{0}} and this is {1}", _zero, _one));
show_debug_message(string("This is some {{0}} and this is {1}", "zero", "one"));

The result is:

This is some {zero} and this is one
This is some {0} and this is one

That's presumably because C# escapes double-braces as non-placeholder single braces, while runtime simply searches and replaces "digits between braces" pattern.

Which version of GameMaker are you reporting this issue for?

IDE v2024.1100.0.700 Runtime v2024.1100.0.718

Which operating system(s) are you seeing the problem on?

Windows 10.0.19045.0

Which platform(s) are you seeing the problem on?

HTML5, Windows

a7695c1c-4a00-4b58-a231-9667d33eaf28

@gm-bug-reporter gm-bug-reporter bot added the runner-bug In-game bugs with the "GameMaker Studio 2" runtimes label Nov 29, 2024
@stuckie stuckie moved this from Triage to Backlog in Team Workload Dec 2, 2024
@DiasFranciscoA DiasFranciscoA moved this from Backlog to In Progress in Team Workload Dec 5, 2024
@DiasFranciscoA DiasFranciscoA added this to the 2024.13 milestone Dec 5, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Team Workload Dec 5, 2024
@YYBartT YYBartT added the documentation Improvements or additions to documentation are required by this issue label Dec 5, 2024
@YYBartT YYBartT self-assigned this Dec 5, 2024
YYBartT added a commit to YoYoGames/GameMaker-Manual that referenced this issue Dec 6, 2024
…d compile time

YoYoGames/GameMaker-Bugs#8564

* string() function page:
  * Added the situations in which curly braces aren't replaced in a format string
  * Added that curly braces can be escaped by doubling them, e.g. "{{" and "}}"
@YYBartT
Copy link

YYBartT commented Dec 6, 2024

Added a paragraph on the string() manual page that mentions when curly braces in a format string are not replaced and how they can be escaped.

@mgeddesGM
Copy link

verified as of IDE v2024.1300.0.719 Runtime v2024.1300.0.731

@mgeddesGM mgeddesGM moved this from Ready for QA to Verified in Team Workload Jan 14, 2025
@YYDan YYDan changed the title string inconsistent braces handling between runtime and compile time In-Game: string() does not support {{ and }} to escape the brace characters Jan 16, 2025
@YYDan YYDan added feature request New feature (or a request for one) and removed runner-bug In-game bugs with the "GameMaker Studio 2" runtimes labels Jan 16, 2025
@YYDan YYDan changed the title In-Game: string() does not support {{ and }} to escape the brace characters In-Game: string() should add support for {{ and }} to escape the brace characters Jan 16, 2025
@YYDan YYDan changed the title In-Game: string() should add support for {{ and }} to escape the brace characters In-Game: string() and show_debug_message() should add support for {{ and }} to escape the brace characters Jan 16, 2025
@YYDan
Copy link
Collaborator

YYDan commented Jan 16, 2025

Note that the same change was made for show_debug_message() also, so I have added this to the title here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation are required by this issue feature request New feature (or a request for one)
Projects
Status: Verified
Development

No branches or pull requests

4 participants