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

feat: gno type check #1426

Merged
merged 202 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 170 commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
e22a43c
outOfGas log clearly
ltzmaxwell Nov 17, 2023
b9aa15e
patch up
ltzmaxwell Nov 20, 2023
9f57ef7
more test, cover more cases
ltzmaxwell Nov 21, 2023
55e3af8
fix assign type check
ltzmaxwell Nov 21, 2023
af75c9e
fixup
ltzmaxwell Nov 27, 2023
2603f34
more test
ltzmaxwell Nov 28, 2023
1275f9d
fixup
ltzmaxwell Nov 29, 2023
814354b
make test work
ltzmaxwell Nov 30, 2023
0f53121
fixup
ltzmaxwell Dec 1, 2023
ddd2c71
refactor
ltzmaxwell Dec 3, 2023
7acaec6
fixup
ltzmaxwell Dec 4, 2023
e291e56
comparable
ltzmaxwell Dec 5, 2023
ad87127
compare
ltzmaxwell Dec 5, 2023
7d21ff8
unary
ltzmaxwell Dec 5, 2023
9b0ace9
fixup
ltzmaxwell Dec 6, 2023
eed16b7
optimize
ltzmaxwell Dec 7, 2023
1c93d2c
inc,dec
ltzmaxwell Dec 7, 2023
5f0ac87
fixup
ltzmaxwell Dec 7, 2023
d6000c5
fixup
ltzmaxwell Dec 7, 2023
812e64d
fixup
ltzmaxwell Dec 7, 2023
fe948bb
doc
ltzmaxwell Dec 7, 2023
52d8221
more test
ltzmaxwell Dec 8, 2023
ec6fd0e
readme
ltzmaxwell Dec 8, 2023
cde9ed5
fixup
ltzmaxwell Dec 8, 2023
80508da
fixup
ltzmaxwell Dec 8, 2023
7af6623
restore unwanted
ltzmaxwell Dec 8, 2023
55e6cc0
restore
ltzmaxwell Dec 8, 2023
6d56167
Merge remote-tracking branch 'upstream/master' into ltzmaxwell/fix/in…
ltzmaxwell Dec 8, 2023
fa7f8d4
restore
ltzmaxwell Dec 8, 2023
6a31cb8
restore
ltzmaxwell Dec 8, 2023
0b095c3
restore
ltzmaxwell Dec 8, 2023
34588a1
restore
ltzmaxwell Dec 8, 2023
edc8c5b
restore
ltzmaxwell Dec 8, 2023
1513d78
restore
ltzmaxwell Dec 8, 2023
5dbf7f4
sync
ltzmaxwell Dec 8, 2023
9656056
fix inc float
ltzmaxwell Dec 8, 2023
fa3acd0
fixup
ltzmaxwell Dec 8, 2023
068e368
fixup
ltzmaxwell Dec 8, 2023
2f4136f
fmt
ltzmaxwell Dec 8, 2023
1497c4a
lint
ltzmaxwell Dec 8, 2023
709e13a
lint
ltzmaxwell Dec 8, 2023
8fd16fc
fix map comparable
ltzmaxwell Dec 8, 2023
8a63e0c
fixup
ltzmaxwell Dec 10, 2023
ad8768b
fix slice type
ltzmaxwell Dec 11, 2023
0f828f5
fix comparable
ltzmaxwell Dec 11, 2023
937723e
fixup
ltzmaxwell Dec 11, 2023
218c834
fixup
ltzmaxwell Dec 11, 2023
8c5ce24
fixup
ltzmaxwell Dec 12, 2023
abff073
fixup
ltzmaxwell Dec 12, 2023
af0de11
fixup
ltzmaxwell Dec 12, 2023
e673dac
fixup
ltzmaxwell Dec 12, 2023
cfcbdda
restore
ltzmaxwell Dec 12, 2023
268e849
fix shift
ltzmaxwell Dec 12, 2023
097244e
fixup
ltzmaxwell Dec 12, 2023
6858e80
fixup
ltzmaxwell Dec 13, 2023
db12d88
tidy
ltzmaxwell Dec 13, 2023
fe2cb7d
fixup
ltzmaxwell Dec 14, 2023
5f58979
fixup
ltzmaxwell Dec 14, 2023
c936fea
fix special case relate to nil type
ltzmaxwell Dec 18, 2023
ee408c2
fixup
ltzmaxwell Dec 19, 2023
2771649
fixup
ltzmaxwell Dec 20, 2023
005b370
fixup
ltzmaxwell Dec 22, 2023
c1f4dda
fixup
ltzmaxwell Dec 22, 2023
f94e4fd
add test
ltzmaxwell Dec 22, 2023
635decd
fixup
ltzmaxwell Dec 24, 2023
95214af
add new test
ltzmaxwell Jan 9, 2024
7464ac9
fixup
ltzmaxwell Jan 11, 2024
4f370a2
clean
ltzmaxwell Jan 11, 2024
54b255d
add comments
ltzmaxwell Jan 11, 2024
184f526
add comment
ltzmaxwell Jan 11, 2024
6aa1c04
add comments
ltzmaxwell Jan 11, 2024
46ced47
add test
ltzmaxwell Jan 11, 2024
5e9c783
add test
ltzmaxwell Jan 11, 2024
9e47ced
fixup
ltzmaxwell Jan 11, 2024
937a725
update
ltzmaxwell Jan 12, 2024
57bd724
update
ltzmaxwell Jan 13, 2024
e9a3a0a
fixup
ltzmaxwell Jan 13, 2024
ef21103
fixup
ltzmaxwell Jan 13, 2024
37f00df
improve name
ltzmaxwell Jan 13, 2024
1791a34
fixup
ltzmaxwell Jan 14, 2024
073bd48
fixup
ltzmaxwell Jan 14, 2024
df4d4c7
fixup
ltzmaxwell Jan 15, 2024
ef25c1f
fixup
ltzmaxwell Jan 15, 2024
6f59149
fixup
ltzmaxwell Jan 15, 2024
33ec34f
fixup
ltzmaxwell Jan 16, 2024
836941d
sync and test
ltzmaxwell Jan 16, 2024
8d3d855
fixup
ltzmaxwell Jan 17, 2024
e4e5e2a
check nil
ltzmaxwell Jan 17, 2024
8ee9724
fixup
ltzmaxwell Jan 17, 2024
292b038
clear
ltzmaxwell Jan 18, 2024
cd8caa9
fixup
ltzmaxwell Jan 18, 2024
87f3a8e
fixup
ltzmaxwell Jan 18, 2024
792a368
fixup
ltzmaxwell Jan 18, 2024
7a9b8a4
add check
ltzmaxwell Jan 20, 2024
94262aa
clean most debug log, can be revert here
ltzmaxwell Jan 31, 2024
afde8b0
escape op on render side
ltzmaxwell Feb 8, 2024
40ec493
migrate logic to type_check.go; move compatibility check as method of…
ltzmaxwell Mar 1, 2024
5f0cf8b
make test pass
ltzmaxwell Mar 1, 2024
cbdc979
done refactor to type_checker
ltzmaxwell Mar 4, 2024
118598d
clean
ltzmaxwell Mar 5, 2024
33a3c9d
prepared for split
ltzmaxwell Mar 5, 2024
6d6590a
mv some check logic to type_check
ltzmaxwell Mar 5, 2024
218fff0
fix binary non-const native handling
ltzmaxwell Mar 7, 2024
a6838b6
fix compatible check for assign in type_check
ltzmaxwell Mar 7, 2024
4744d09
make rhs native type check in type_check
ltzmaxwell Mar 8, 2024
5631d3a
try handle checking declared type against native interface, temp her…
ltzmaxwell Mar 11, 2024
a2862ba
consolidate delay handling for untyped shift expr logic
ltzmaxwell Mar 13, 2024
7bd03e1
cache better; clear unused logic
ltzmaxwell Mar 14, 2024
f9517eb
#cherry-pick. rm logic of check declared type against native interfac…
ltzmaxwell Mar 14, 2024
88f20ea
#no cherry pick for shift_expr_typecheck branch! rm most logic for ha…
ltzmaxwell Mar 14, 2024
5da2910
cherry pick this. rm remained logic for check against native interfac…
ltzmaxwell Mar 14, 2024
723aa3b
default cherry pick commit this branch if not marked as not. fixup
ltzmaxwell Mar 14, 2024
c93111f
restore typecheck, rm redundant checkAssignableTo, leave it to checkO…
ltzmaxwell Apr 4, 2024
64dc20d
clean
ltzmaxwell Apr 4, 2024
a65be41
clean
ltzmaxwell Apr 4, 2024
953765c
clean
ltzmaxwell Apr 4, 2024
6f22a56
split type_compare(wtf) and type(nil)
ltzmaxwell Apr 4, 2024
6908950
restore
ltzmaxwell Apr 4, 2024
0c79c67
split type def on pointer type & clean
ltzmaxwell Apr 4, 2024
cc5c8c8
rm no use file
ltzmaxwell Apr 4, 2024
5f9a362
clean
ltzmaxwell Apr 5, 2024
cb338ce
for binaryExpr, also check xt
ltzmaxwell Apr 7, 2024
d3af8c3
split implicit type conversion feat
ltzmaxwell Apr 7, 2024
5b83cdb
add test
ltzmaxwell Apr 8, 2024
3d148f6
add test
ltzmaxwell Apr 8, 2024
7925202
check bigdec, add comments
ltzmaxwell Apr 8, 2024
2f780d5
clean
ltzmaxwell Apr 10, 2024
a89aea3
type check for assignStmt
ltzmaxwell Apr 11, 2024
cfe75b7
type check for assignStmt, fixup assertion
ltzmaxwell Apr 11, 2024
d427e79
fix render issure with %
ltzmaxwell Apr 12, 2024
4fb88d8
Update gnovm/pkg/gnolang/type_check.go
ltzmaxwell Apr 13, 2024
ac6d5cb
Update gnovm/pkg/gnolang/type_check.go
ltzmaxwell Apr 13, 2024
83cacc6
Update gnovm/pkg/gnolang/type_check.go
ltzmaxwell Apr 13, 2024
0cfe9b8
Update gnovm/Makefile
ltzmaxwell Apr 15, 2024
bed7e3c
clean
ltzmaxwell Apr 16, 2024
3a827be
Merge remote-tracking branch 'origin/ltzmaxwell/fix/interface_compari…
ltzmaxwell Apr 16, 2024
b7e6f5a
update
ltzmaxwell Apr 17, 2024
0d767a4
fix assertComparable
ltzmaxwell Apr 17, 2024
7fe0504
simplify assertComparable logic
ltzmaxwell Apr 17, 2024
681f285
Update gnovm/pkg/gnolang/preprocess.go
ltzmaxwell Apr 18, 2024
603c39a
Update gnovm/pkg/gnolang/type_check.go
ltzmaxwell Apr 18, 2024
1919aa3
Update gnovm/pkg/gnolang/type_check.go
ltzmaxwell Apr 18, 2024
7699ab0
decouple checkOrConvertType
ltzmaxwell Apr 18, 2024
8b7aaa3
update
ltzmaxwell Apr 18, 2024
5f95c6c
improve assertComparable, rm interface{}(nil) test file
ltzmaxwell Apr 18, 2024
1caac46
fix CI
ltzmaxwell Apr 18, 2024
f4c9e66
revert unuseful logic
ltzmaxwell Apr 18, 2024
850e4e3
more check
ltzmaxwell Apr 19, 2024
7467a2d
clean
ltzmaxwell Apr 19, 2024
4b13980
not check on define in assignment
ltzmaxwell Apr 20, 2024
63fd8cc
rm similar test file with multi operators
ltzmaxwell Apr 21, 2024
abc1677
clean
ltzmaxwell Apr 21, 2024
3c3d939
simplify binary type check
ltzmaxwell Apr 22, 2024
f6764d9
clear
ltzmaxwell Apr 22, 2024
986d8ec
fixup
ltzmaxwell Apr 22, 2024
97f46cd
fixup
ltzmaxwell Apr 22, 2024
1819db7
assert valie left value
ltzmaxwell Apr 22, 2024
d00e506
merge master and resolve conflicts
ltzmaxwell Apr 25, 2024
a167478
fix linter
ltzmaxwell Apr 25, 2024
ff437b4
fixup
ltzmaxwell Apr 25, 2024
500f984
resolve comments
ltzmaxwell May 2, 2024
1eabcce
simplify cmpSpecificity
ltzmaxwell May 2, 2024
1e72c38
fix range assign
ltzmaxwell May 2, 2024
ff57c36
revert
ltzmaxwell May 13, 2024
77f933e
merge master
ltzmaxwell May 13, 2024
9137217
fixup
ltzmaxwell May 24, 2024
9a96287
fixup, revert recursive check
ltzmaxwell May 24, 2024
1d65b4c
fixup
ltzmaxwell May 24, 2024
26efc94
optimize
ltzmaxwell May 24, 2024
9a2acb9
improve readibility for recursive call
ltzmaxwell May 27, 2024
07d52f9
fix lint
ltzmaxwell Jun 2, 2024
9af1aa7
fixup
ltzmaxwell Jun 3, 2024
bf202eb
merger master
ltzmaxwell Jun 3, 2024
627ef95
fix
ltzmaxwell Jun 3, 2024
329ddb8
Revert "merger master"
ltzmaxwell Jun 3, 2024
168ea29
merge master
ltzmaxwell Jun 3, 2024
641cd7f
make test pass
ltzmaxwell Jun 3, 2024
65a7ca3
rename test files
ltzmaxwell Jun 12, 2024
c0a76c2
clear log
ltzmaxwell Jun 12, 2024
01648dd
rename
ltzmaxwell Jun 12, 2024
9bd5c2f
del
ltzmaxwell Jun 12, 2024
815c8d5
Merge remote-tracking branch 'upstream/master' into ltzmaxwell/fix/in…
ltzmaxwell Jun 12, 2024
649d65d
better msg
ltzmaxwell Jun 12, 2024
950801a
bypass
ltzmaxwell Jun 12, 2024
0530f41
fix import
ltzmaxwell Jun 12, 2024
2512070
fixup tests zrealm12
ltzmaxwell Jun 12, 2024
33357f9
print
ltzmaxwell Jun 12, 2024
646743e
Merge branch 'fix/maxwell/zrealm12' into ltzmaxwell/fix/interface_com…
ltzmaxwell Jun 12, 2024
c1162db
fixup
ltzmaxwell Jun 13, 2024
fbe31dc
fix linter
ltzmaxwell Jun 13, 2024
b0850b2
fixup
ltzmaxwell Jun 13, 2024
4292a3f
...
jaekwon Jun 18, 2024
2f5b613
...
jaekwon Jun 18, 2024
0891153
switch test mode
jaekwon Jun 18, 2024
c1abcf7
fix check on both typed, no conversion
ltzmaxwell Jun 17, 2024
98ad2b2
unified/correct check logic for both typed
ltzmaxwell Jun 17, 2024
8c2a3cf
fixup checkOrConvertType
ltzmaxwell Jun 17, 2024
d92c4eb
more comment
ltzmaxwell Jun 18, 2024
bb20640
...
jaekwon Jun 19, 2024
ea969b3
Revert "fix: default untyped to uint when necessary (#2024)"
jaekwon Jun 19, 2024
a1278f6
Merge branch 'ltzmaxwell/fix/interface_comparison'
jaekwon Jun 19, 2024
0ced1b7
...
jaekwon Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/gnovm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ jobs:
- _test.pkg
- _test.gnolang.native
- _test.gnolang.stdlibs
- _test.gnolang.types
- _test.gnolang.types.native
- _test.gnolang.realm
- _test.gnolang.pkg0
- _test.gnolang.pkg1
Expand Down
5 changes: 3 additions & 2 deletions examples/gno.land/p/demo/memeland/memeland_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

"gno.land/p/demo/seqid"
"gno.land/p/demo/testutils"
"gno.land/p/demo/ufmt"
)
Expand Down Expand Up @@ -97,7 +98,7 @@ func TestGetPostsInRangeByTimestamp(t *testing.T) {

// Count the number of posts returned in the JSON string as a rudimentary check for correct pagination/filtering
postCount := strings.Count(jsonStr, `"id":"`)
if postCount != m.MemeCounter {
if seqid.ID(postCount) != m.MemeCounter {
leohhhn marked this conversation as resolved.
Show resolved Hide resolved
t.Errorf("Expected %d posts in the JSON string, but found %d", m.MemeCounter, postCount)
}

Expand Down Expand Up @@ -157,7 +158,7 @@ func TestGetPostsInRangeByUpvote(t *testing.T) {

// Count the number of posts returned in the JSON string as a rudimentary check for correct pagination/filtering
postCount := strings.Count(jsonStr, `"id":"`)
if postCount != m.MemeCounter {
if seqid.ID(postCount) != m.MemeCounter {
t.Errorf("Expected %d posts in the JSON string, but found %d", m.MemeCounter, postCount)
}

Expand Down
7 changes: 6 additions & 1 deletion gnovm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ _test.pkg:
go test ./pkg/... $(GOTEST_FLAGS)

.PHONY: _test.gnolang
_test.gnolang: _test.gnolang.native _test.gnolang.stdlibs _test.gnolang.realm _test.gnolang.pkg0 _test.gnolang.pkg1 _test.gnolang.pkg2 _test.gnolang.other
_test.gnolang: _test.gnolang.types _test.gnolang.types.native _test.gnolang.native _test.gnolang.stdlibs _test.gnolang.realm _test.gnolang.pkg0 _test.gnolang.pkg1 _test.gnolang.pkg2 _test.gnolang.other
_test.gnolang.other:; go test tests/*.go -run "(TestFileStr|TestSelectors)" $(GOTEST_FLAGS)
_test.gnolang.realm:; go test tests/*.go -run "TestFiles/^zrealm" $(GOTEST_FLAGS)
_test.gnolang.pkg0:; go test tests/*.go -run "TestPackages/(bufio|crypto|encoding|errors|internal|io|math|sort|std|stdshim|strconv|strings|testing|unicode)" $(GOTEST_FLAGS)
Expand All @@ -81,6 +81,11 @@ _test.gnolang.native:; go test tests/*.go -test.short -run "TestFilesNativ
_test.gnolang.stdlibs:; go test tests/*.go -test.short -run 'TestFiles$$/' $(GOTEST_FLAGS)
_test.gnolang.native.sync:; go test tests/*.go -test.short -run "TestFilesNative/" --update-golden-tests $(GOTEST_FLAGS)
_test.gnolang.stdlibs.sync:; go test tests/*.go -test.short -run 'TestFiles$$/' --update-golden-tests $(GOTEST_FLAGS)
# NOTE: challenges are current GnoVM bugs which are supposed to fail.
# If any of these tests pass, it should be moved to a normal test.
_test.gnolang.challenges:; go test tests/*.go -test.short -run 'TestChallenges$$/' $(GOTEST_FLAGS)
ltzmaxwell marked this conversation as resolved.
Show resolved Hide resolved
_test.gnolang.types:; go test tests/*.go -test.short -run 'TestTypes$$/' $(GOTEST_FLAGS)
_test.gnolang.types.native:; go test tests/*.go -test.short -run 'TestTypesNative$$/' $(GOTEST_FLAGS)

########################################
# Code gen
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/gonative.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ func gno2GoType(t Type) reflect.Type {

// If gno2GoTypeMatches(t, rt) is true, a t value can
// be converted to an rt native value using gno2GoValue(v, rv).
// This is called when autoNative is true in checkType().
// This is called when autoNative is true in assertAssignableTo().
// This is used for all native function calls, and also
// for testing whether a native value implements a gno interface.
func gno2GoTypeMatches(t Type, rt reflect.Type) (result bool) {
Expand Down
Loading