Skip to content

Commit 239b56e

Browse files
fixed bug with error supression, cleaned up init.luau a little bit
1 parent 01b8582 commit 239b56e

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v3.0.1
2+
- Fixes issues with assertions not properly throwing an error in certain scenarios.
3+
14
# v3.0.0
25
- Now documenting changes via a changelog.
3-
- Fixed type errors.
6+
- Fixed type errors.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Typeforge
2+
23
A Type Function utility library for Luau.
34

5+
> [!TIP]
6+
> Check out [Typebrick](https://github.com/typeforge-luau/typebrick), type function utilities for Roblox.
7+
48
docs: http://typeforge.luau.page/
59

6-
wally: https://wally.run/package/cameronpcampbell/typeforge
10+
wally: https://wally.run/package/cameronpcampbell/typeforge

rokit.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55

66
[tools]
77
wally = "UpliftGames/wally@0.3.2"
8-
lune = "lune-org/lune@0.9.3"

src/init.luau

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type function assert_is(input: type, label: string, input_tag: string, ...: stri
3636
if select("#", ...) == 1 then
3737
local is = ...
3838
if input_type ~= is then
39-
assert_is_msg(input, input_type, label, `'{is}'`)
39+
error(assert_is_msg(input, input_type, label, `'{is}'`))
4040
end
4141

4242
else
@@ -693,6 +693,25 @@ type function table_value_swap_remove(input: { [any]: any }, input_len: number,
693693
return input_len - 1
694694
end
695695

696+
-- Sets the value of a table in a way which works around the
697+
-- erroneously seperated read and write fields in type hints issue.
698+
type function table_set_property(
699+
input: type,
700+
key: type,
701+
value: { read: type?, write: type? }?
702+
)
703+
if value == nil then return end
704+
705+
local value_read, value_write = value.read, value.write
706+
if value_read == value_write then
707+
input:setproperty(key, value_read)
708+
709+
else
710+
input:setreadproperty(key, value_read)
711+
input:setwriteproperty(key, value_write)
712+
end
713+
end
714+
696715
type function table_value_is_empty(properties: { [any]: any }, indexer: type)
697716
if indexer then return false end
698717

@@ -796,14 +815,7 @@ type function table_remove_indexer_hacky_fix(input: typeof(types.newtable()))
796815
local output = types.newtable()
797816

798817
for key, value in input:properties() do
799-
local value_read, value_write = value.read, value.write
800-
if value_read == value_write then
801-
output:setproperty(key, value_read)
802-
803-
else
804-
output:setreadproperty(key, value_read)
805-
output:setwriteproperty(key, value_write)
806-
end
818+
table_set_property(output, key, value)
807819
end
808820

809821
return output
@@ -817,14 +829,7 @@ type function table_remove_read_indexer_hacky_fix(input: typeof(types.newtable()
817829
local output = types.newtable()
818830

819831
for key, value in input:properties() do
820-
local value_read, value_write = value.read, value.write
821-
if value_read == value_write then
822-
output:setproperty(key, value_read)
823-
824-
else
825-
output:setreadproperty(key, value_read)
826-
output:setwriteproperty(key, value_write)
827-
end
832+
table_set_property(output, key, value)
828833
end
829834

830835
local indexer = input:indexer()
@@ -846,14 +851,7 @@ type function table_remove_write_indexer_hacky_fix(input: typeof(types.newtable(
846851
local output = types.newtable()
847852

848853
for key, value in input:properties() do
849-
local value_read, value_write = value.read, value.write
850-
if value_read == value_write then
851-
output:setproperty(key, value_read)
852-
853-
else
854-
output:setreadproperty(key, value_read)
855-
output:setwriteproperty(key, value_write)
856-
end
854+
table_set_property(output, key, value)
857855
end
858856

859857
local indexer = input:indexer()

0 commit comments

Comments
 (0)