YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

Unexpected output from math, string, and random functions #8088

Open tinkerer-red opened 2 hours ago

tinkerer-red commented 2 hours ago

Description

There are several functions which are expected to throw an error, or return undefined when no arguments are provided. Though all of the ones list below return varying degrees of expected results. I initially thought this was due to compile time optimizations, but a few of these in the html5 runtime source show these are intentional. As well as all of them report the same outputs in LTS.

Example of all the errors thrown by feather. image

Expected Change

All of the following functions should either throw errors when this occurs, or return undefined. Though an argument could be made for a few of these but exceptions to the rule makes for unpredictability.

Steps To Reproduce

Here is a list of functions which are compiled, and executed just fine, despite documentation, feather, and GmlSpec stating otherwise.

show_debug_message($"choose() == {choose()} :: With typeof == {typeof(choose())}")
// Output :: choose() == 0 :: With typeof == number

show_debug_message($"max() == {max()} :: With typeof == {typeof(max())}")
// Output :: max() == 0 :: With typeof == number

show_debug_message($"mean() == {mean()} :: With typeof == {typeof(mean())}")
// Output :: mean() == 0 :: With typeof == number

show_debug_message($"median() == {median()} :: With typeof == {typeof(median())}")
// Output :: median() == 0 :: With typeof == number

show_debug_message($"min() == {min()} :: With typeof == {typeof(min())}")
// Output :: min() == 0 :: With typeof == number

show_debug_message($"string_join_ext() == {string_join_ext()} :: With typeof == {typeof(string_join_ext())}")
// Output :: string_join_ext() ==  :: With typeof == string

show_debug_message($"string() == {string()} :: With typeof == {typeof(string())}")
// Output :: string() == string :: With typeof == string

show_debug_message($"string_join() == {string_join()} :: With typeof == {typeof(string_join())}")
// Output :: string_join() ==  :: With typeof == string

Additionally, There is another bug related specifically with string() notice how the output specifically for string() is different depending on the order. The same is true above, normally show_debug_message(string()) prints 0.00

show_debug_message($"{typeof(string())} = {string()}")
// Output :: string = 0.00
show_debug_message($"{string()} == {typeof(string())}")
// Output :: string == string

A further report for this has been started for #8090

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

2024.8.1 (Monthly), 2022.0.2 (LTS)

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

Windows 10

Are you running GameMaker from inside your Steam library?

None

Sample Package Attached?

Sample Project Added?

https://api.gamemaker.io/api/github/downloads/a76af28d-c457-415e-8775-0de4bc4eb14a

tinkerer-red commented 2 hours ago

Additionally I have tested the following pure functions to ensure they did not produce similar results. All of these will prevent compiling.

log($"abs() == {abs()} :: With typeof == {typeof(abs())}")
log($"angle_difference() == {angle_difference()} :: With typeof == {typeof(angle_difference())}")
log($"ansi_char() == {ansi_char()} :: With typeof == {typeof(ansi_char())}")
log($"arccos() == {arccos()} :: With typeof == {typeof(arccos())}")
log($"arcsin() == {arcsin()} :: With typeof == {typeof(arcsin())}")
log($"arctan() == {arctan()} :: With typeof == {typeof(arctan())}")
log($"arctan2() == {arctan2()} :: With typeof == {typeof(arctan2())}")
log($"buffer_sizeof() == {buffer_sizeof()} :: With typeof == {typeof(buffer_sizeof())}")
log($"ceil() == {ceil()} :: With typeof == {typeof(ceil())}")
log($"chr() == {chr()} :: With typeof == {typeof(chr())}")
log($"clamp() == {clamp()} :: With typeof == {typeof(clamp())}")
log($"color_get_blue() == {color_get_blue()} :: With typeof == {typeof(color_get_blue())}")
log($"color_get_green() == {color_get_green()} :: With typeof == {typeof(color_get_green())}")
log($"color_get_red() == {color_get_red()} :: With typeof == {typeof(color_get_red())}")
log($"colour_get_blue() == {colour_get_blue()} :: With typeof == {typeof(colour_get_blue())}")
log($"colour_get_green() == {colour_get_green()} :: With typeof == {typeof(colour_get_green())}")
log($"colour_get_red() == {colour_get_red()} :: With typeof == {typeof(colour_get_red())}")
log($"cos() == {cos()} :: With typeof == {typeof(cos())}")
log($"darccos() == {darccos()} :: With typeof == {typeof(darccos())}")
log($"darcsin() == {darcsin()} :: With typeof == {typeof(darcsin())}")
log($"darctan() == {darctan()} :: With typeof == {typeof(darctan())}")
log($"darctan2() == {darctan2()} :: With typeof == {typeof(darctan2())}")
log($"dcos() == {dcos()} :: With typeof == {typeof(dcos())}")
log($"degtorad() == {degtorad()} :: With typeof == {typeof(degtorad())}")
log($"dot_product() == {dot_product()} :: With typeof == {typeof(dot_product())}")
log($"dot_product_3d() == {dot_product_3d()} :: With typeof == {typeof(dot_product_3d())}")
log($"dot_product_3d_normalised() == {dot_product_3d_normalised()} :: With typeof == {typeof(dot_product_3d_normalised())}")
log($"dot_product_normalised() == {dot_product_normalised()} :: With typeof == {typeof(dot_product_normalised())}")
log($"dsin() == {dsin()} :: With typeof == {typeof(dsin())}")
log($"dtan() == {dtan()} :: With typeof == {typeof(dtan())}")
log($"exp() == {exp()} :: With typeof == {typeof(exp())}")
log($"floor() == {floor()} :: With typeof == {typeof(floor())}")
log($"frac() == {frac()} :: With typeof == {typeof(frac())}")
log($"int64() == {int64()} :: With typeof == {typeof(int64())}")
log($"is_array() == {is_array()} :: With typeof == {typeof(is_array())}")
log($"is_bool() == {is_bool()} :: With typeof == {typeof(is_bool())}")
log($"is_callable() == {is_callable()} :: With typeof == {typeof(is_callable())}")
log($"is_handle() == {is_handle()} :: With typeof == {typeof(is_handle())}")
log($"is_infinity() == {is_infinity()} :: With typeof == {typeof(is_infinity())}")
log($"is_int32() == {is_int32()} :: With typeof == {typeof(is_int32())}")
log($"is_method() == {is_method()} :: With typeof == {typeof(is_method())}")
log($"is_nan() == {is_nan()} :: With typeof == {typeof(is_nan())}")
log($"is_numeric() == {is_numeric()} :: With typeof == {typeof(is_numeric())}")
log($"is_ptr() == {is_ptr()} :: With typeof == {typeof(is_ptr())}")
log($"is_struct() == {is_struct()} :: With typeof == {typeof(is_struct())}")
log($"is_undefined() == {is_undefined()} :: With typeof == {typeof(is_undefined())}")
log($"lengthdir_x() == {lengthdir_x()} :: With typeof == {typeof(lengthdir_x())}")
log($"lengthdir_y() == {lengthdir_y()} :: With typeof == {typeof(lengthdir_y())}")
log($"lerp() == {lerp()} :: With typeof == {typeof(lerp())}")
log($"ln() == {ln()} :: With typeof == {typeof(ln())}")
log($"log10() == {log10()} :: With typeof == {typeof(log10())}")
log($"log2() == {log2()} :: With typeof == {typeof(log2())}")
log($"logn() == {logn()} :: With typeof == {typeof(logn())}")
log($"make_color_rgb() == {make_color_rgb()} :: With typeof == {typeof(make_color_rgb())}")
log($"make_colour_rgb() == {make_colour_rgb()} :: With typeof == {typeof(make_colour_rgb())}")
log($"object_exists() == {object_exists()} :: With typeof == {typeof(object_exists())}")
log($"object_get_name() == {object_get_name()} :: With typeof == {typeof(object_get_name())}")
log($"object_get_parent() == {object_get_parent()} :: With typeof == {typeof(object_get_parent())}")
log($"object_get_physics() == {object_get_physics()} :: With typeof == {typeof(object_get_physics())}")
log($"object_is_ancestor() == {object_is_ancestor()} :: With typeof == {typeof(object_is_ancestor())}")
log($"ord() == {ord()} :: With typeof == {typeof(ord())}")
log($"point_direction() == {point_direction()} :: With typeof == {typeof(point_direction())}")
log($"point_distance() == {point_distance()} :: With typeof == {typeof(point_distance())}")
log($"point_distance_3d() == {point_distance_3d()} :: With typeof == {typeof(point_distance_3d())}")
log($"power() == {power()} :: With typeof == {typeof(power())}")
log($"radtodeg() == {radtodeg()} :: With typeof == {typeof(radtodeg())}")
log($"real() == {real()} :: With typeof == {typeof(real())}")
log($"round() == {round()} :: With typeof == {typeof(round())}")
log($"script_exists() == {script_exists()} :: With typeof == {typeof(script_exists())}")
log($"script_get_name() == {script_get_name()} :: With typeof == {typeof(script_get_name())}")
log($"sign() == {sign()} :: With typeof == {typeof(sign())}")
log($"sin() == {sin()} :: With typeof == {typeof(sin())}")
log($"sqr() == {sqr()} :: With typeof == {typeof(sqr())}")
log($"sqrt() == {sqrt()} :: With typeof == {typeof(sqrt())}")
log($"string_lower() == {string_lower()} :: With typeof == {typeof(string_lower())}")
log($"string_upper() == {string_upper()} :: With typeof == {typeof(string_upper())}")
log($"string_repeat() == {string_repeat()} :: With typeof == {typeof(string_repeat())}")
log($"tan() == {tan()} :: With typeof == {typeof(tan())}")
log($"string_byte_length() == {string_byte_length()} :: With typeof == {typeof(string_byte_length())}")
log($"string_char_at() == {string_char_at()} :: With typeof == {typeof(string_char_at())}")
log($"string_copy() == {string_copy()} :: With typeof == {typeof(string_copy())}")
log($"string_count() == {string_count()} :: With typeof == {typeof(string_count())}")
log($"string_delete() == {string_delete()} :: With typeof == {typeof(string_delete())}")
log($"string_digits() == {string_digits()} :: With typeof == {typeof(string_digits())}")
log($"string_ends_with() == {string_ends_with()} :: With typeof == {typeof(string_ends_with())}")
log($"string_ext() == {string_ext()} :: With typeof == {typeof(string_ext())}")
log($"string_format() == {string_format()} :: With typeof == {typeof(string_format())}")
log($"string_hash_to_newline() == {string_hash_to_newline()} :: With typeof == {typeof(string_hash_to_newline())}")
log($"string_insert() == {string_insert()} :: With typeof == {typeof(string_insert())}")
log($"string_last_pos() == {string_last_pos()} :: With typeof == {typeof(string_last_pos())}")
log($"string_last_pos_ext() == {string_last_pos_ext()} :: With typeof == {typeof(string_last_pos_ext())}")
log($"string_length() == {string_length()} :: With typeof == {typeof(string_length())}")
log($"string_letters() == {string_letters()} :: With typeof == {typeof(string_letters())}")
log($"string_ord_at() == {string_ord_at()} :: With typeof == {typeof(string_ord_at())}")
log($"string_pos() == {string_pos()} :: With typeof == {typeof(string_pos())}")
log($"string_pos_ext() == {string_pos_ext()} :: With typeof == {typeof(string_pos_ext())}")
log($"string_replace() == {string_replace()} :: With typeof == {typeof(string_replace())}")
log($"string_replace_all() == {string_replace_all()} :: With typeof == {typeof(string_replace_all())}")
log($"string_set_byte_at() == {string_set_byte_at()} :: With typeof == {typeof(string_set_byte_at())}")
log($"string_starts_with() == {string_starts_with()} :: With typeof == {typeof(string_starts_with())}")
log($"md5_string_unicode() == {md5_string_unicode()} :: With typeof == {typeof(md5_string_unicode())}")
log($"md5_string_utf8() == {md5_string_utf8()} :: With typeof == {typeof(md5_string_utf8())}")
log($"color_get_hue() == {color_get_hue()} :: With typeof == {typeof(color_get_hue())}")
log($"colour_get_hue() == {colour_get_hue()} :: With typeof == {typeof(colour_get_hue())}")
log($"color_get_saturation() == {color_get_saturation()} :: With typeof == {typeof(color_get_saturation())}")
log($"colour_get_saturation() == {colour_get_saturation()} :: With typeof == {typeof(colour_get_saturation())}")
log($"color_get_value() == {color_get_value()} :: With typeof == {typeof(color_get_value())}")
log($"colour_get_value() == {colour_get_value()} :: With typeof == {typeof(colour_get_value())}")
log($"base64_encode() == {base64_encode()} :: With typeof == {typeof(base64_encode())}")
log($"base64_decode() == {base64_decode()} :: With typeof == {typeof(base64_decode())}")
log($"sha1_string_utf8() == {sha1_string_utf8()} :: With typeof == {typeof(sha1_string_utf8())}")
log($"sha1_string_unicode() == {sha1_string_unicode()} :: With typeof == {typeof(sha1_string_unicode())}")
log($"make_color_hsv() == {make_color_hsv()} :: With typeof == {typeof(make_color_hsv())}")
log($"make_colour_hsv() == {make_colour_hsv()} :: With typeof == {typeof(make_colour_hsv())}")

And these functions compile, yet do indeed throw an error:

log($"string_trim() == {string_trim()} :: With typeof == {typeof(string_trim())}")
log($"string_trim_end() == {string_trim_end()} :: With typeof == {typeof(string_trim_end())}")
log($"string_trim_start() == {string_trim_start()} :: With typeof == {typeof(string_trim_start())}")
log($"string_concat() == {string_concat()} :: With typeof == {typeof(string_concat())}")
log($"string_concat_ext() == {string_concat_ext()} :: With typeof == {typeof(string_concat_ext())}")

More information about string_concat_ext can be found in #8089