aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Bug] [Compiler V2] Abort wrongly typed in statements

Open fEst1ck opened this issue 1 year ago • 4 comments

🐛 Bug

abort when used in statements are not typed correctly:

fun test(): u8 {
	// abort(42) // this works
	abort 42; // this doesn't
}

gives error

+ error: expected `u8` but found `()`
+    ┌─ tests/ability-checker/bug.move:14:11
+    │
+    │         abort 42;
+    │                 ^

Interestingly, this type checks

fun test(): u8 {
	if (true) {
		abort 42;
	};
	42
}

Similar issues exist for return.

Expected Behavior

All of the above programs should type check.

fEst1ck avatar Dec 22 '23 03:12 fEst1ck

Need to check whether this is actually working in v1

wrwg avatar Feb 15 '24 21:02 wrwg

What we may need is a heuristic to give error message about missing or superfluous semicolon

wrwg avatar Feb 22 '24 21:02 wrwg

May be related to #11708.

brmataptos avatar Apr 20 '24 06:04 brmataptos

Low priority for v2-stable

wrwg avatar May 23 '24 20:05 wrwg

Confirmed that V1 behaves the same except that it generates the warning unnecessary trailing semicolon. cc @fEst1ck @wrwg

rahxephon89 avatar Jun 02 '24 13:06 rahxephon89

We have already a bug for trailing semicolon, so we can close this one.

wrwg avatar Jun 04 '24 21:06 wrwg