From 03448781ad4aee9a181f4846dd813d822cd6effa Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Thu, 3 Oct 2024 14:24:26 +0100 Subject: [PATCH] add --ai-errors tests --- test/fail/ok/suggest-ai-local.tc.ok | 3 + ...i.tc.ret.ok => suggest-ai-local.tc.ret.ok} | 0 test/fail/ok/suggest-label-ai.tc.ok | 3 + test/fail/ok/suggest-label-ai.tc.ret.ok | 1 + test/fail/ok/suggest-local-ai.tc.ok | 3 + test/fail/ok/suggest-local-ai.tc.ret.ok | 1 + test/fail/ok/suggest-local-type-ai.tc.ok | 30 ++ test/fail/ok/suggest-local-type-ai.tc.ret.ok | 1 + ...suggest-ai.tc.ok => suggest-long-ai.tc.ok} | 2 +- test/fail/ok/suggest-long-ai.tc.ret.ok | 1 + test/fail/ok/suggest-short-ai.tc.ok | 259 ++++++++++++++++++ test/fail/ok/suggest-short-ai.tc.ret.ok | 1 + test/fail/ok/suggest-type-ai.tc.ok | 25 ++ test/fail/ok/suggest-type-ai.tc.ret.ok | 1 + test/fail/suggest-label-ai.mo | 4 + test/fail/suggest-local-ai.mo | 3 + test/fail/suggest-local-type-ai.mo | 3 + test/fail/suggest-long-ai.mo | 4 + test/fail/suggest-short-ai.mo | 4 + test/fail/suggest-type-ai.mo | 4 + 20 files changed, 352 insertions(+), 1 deletion(-) create mode 100644 test/fail/ok/suggest-ai-local.tc.ok rename test/fail/ok/{suggest-ai.tc.ret.ok => suggest-ai-local.tc.ret.ok} (100%) create mode 100644 test/fail/ok/suggest-label-ai.tc.ok create mode 100644 test/fail/ok/suggest-label-ai.tc.ret.ok create mode 100644 test/fail/ok/suggest-local-ai.tc.ok create mode 100644 test/fail/ok/suggest-local-ai.tc.ret.ok create mode 100644 test/fail/ok/suggest-local-type-ai.tc.ok create mode 100644 test/fail/ok/suggest-local-type-ai.tc.ret.ok rename test/fail/ok/{suggest-ai.tc.ok => suggest-long-ai.tc.ok} (99%) create mode 100644 test/fail/ok/suggest-long-ai.tc.ret.ok create mode 100644 test/fail/ok/suggest-short-ai.tc.ok create mode 100644 test/fail/ok/suggest-short-ai.tc.ret.ok create mode 100644 test/fail/ok/suggest-type-ai.tc.ok create mode 100644 test/fail/ok/suggest-type-ai.tc.ret.ok create mode 100644 test/fail/suggest-label-ai.mo create mode 100644 test/fail/suggest-local-ai.mo create mode 100644 test/fail/suggest-local-type-ai.mo create mode 100644 test/fail/suggest-long-ai.mo create mode 100644 test/fail/suggest-short-ai.mo create mode 100644 test/fail/suggest-type-ai.mo diff --git a/test/fail/ok/suggest-ai-local.tc.ok b/test/fail/ok/suggest-ai-local.tc.ok new file mode 100644 index 00000000000..af811c68af3 --- /dev/null +++ b/test/fail/ok/suggest-ai-local.tc.ok @@ -0,0 +1,3 @@ +suggest-ai-local.mo:9.1-9.2: type error [M0057], unbound variable x in environment: + {Foo : module {x : Nat}; xxx : Nat} +The variable x is not available. Try something else? diff --git a/test/fail/ok/suggest-ai.tc.ret.ok b/test/fail/ok/suggest-ai-local.tc.ret.ok similarity index 100% rename from test/fail/ok/suggest-ai.tc.ret.ok rename to test/fail/ok/suggest-ai-local.tc.ret.ok diff --git a/test/fail/ok/suggest-label-ai.tc.ok b/test/fail/ok/suggest-label-ai.tc.ok new file mode 100644 index 00000000000..49c9e4e4aca --- /dev/null +++ b/test/fail/ok/suggest-label-ai.tc.ok @@ -0,0 +1,3 @@ +suggest-label-ai.mo:3.9-3.11: type error [M0083], unbound label fo in label environment: + {foo : ()} +The label fo is not available. Try something else? diff --git a/test/fail/ok/suggest-label-ai.tc.ret.ok b/test/fail/ok/suggest-label-ai.tc.ret.ok new file mode 100644 index 00000000000..69becfa16f9 --- /dev/null +++ b/test/fail/ok/suggest-label-ai.tc.ret.ok @@ -0,0 +1 @@ +Return code 1 diff --git a/test/fail/ok/suggest-local-ai.tc.ok b/test/fail/ok/suggest-local-ai.tc.ok new file mode 100644 index 00000000000..3ea48f96666 --- /dev/null +++ b/test/fail/ok/suggest-local-ai.tc.ok @@ -0,0 +1,3 @@ +suggest-local-ai.mo:3.1-3.2: type error [M0057], unbound variable x in environment: + {xxx : Nat} +The variable x is not available. Try something else? diff --git a/test/fail/ok/suggest-local-ai.tc.ret.ok b/test/fail/ok/suggest-local-ai.tc.ret.ok new file mode 100644 index 00000000000..69becfa16f9 --- /dev/null +++ b/test/fail/ok/suggest-local-ai.tc.ret.ok @@ -0,0 +1 @@ +Return code 1 diff --git a/test/fail/ok/suggest-local-type-ai.tc.ok b/test/fail/ok/suggest-local-type-ai.tc.ok new file mode 100644 index 00000000000..865c760ddf5 --- /dev/null +++ b/test/fail/ok/suggest-local-type-ai.tc.ok @@ -0,0 +1,30 @@ +suggest-local-type-ai.mo:3.13-3.15: type error [M0029], unbound type Fo in type environment: + { + type $ = Any; + type Any = Any; + type Blob = Blob; + type Bool = Bool; + type Char = Char; + type Error = Error; + type Float = Float; + type Foo = Int; + type Int = Int; + type Int16 = Int16; + type Int32 = Int32; + type Int64 = Int64; + type Int8 = Int8; + type Nat = Nat; + type Nat16 = Nat16; + type Nat32 = Nat32; + type Nat64 = Nat64; + type Nat8 = Nat8; + type None = None; + type Null = Null; + type Principal = Principal; + type Region = Region; + type Text = Text; + type UpgradeOptions = {wasm_memory_persistence : ?WasmMemoryPersistence}; + type WasmMemoryPersistence = {#Keep; #Replace}; + type Zap <: ??? + } +The type Fo is not available. Try something else? diff --git a/test/fail/ok/suggest-local-type-ai.tc.ret.ok b/test/fail/ok/suggest-local-type-ai.tc.ret.ok new file mode 100644 index 00000000000..69becfa16f9 --- /dev/null +++ b/test/fail/ok/suggest-local-type-ai.tc.ret.ok @@ -0,0 +1 @@ +Return code 1 diff --git a/test/fail/ok/suggest-ai.tc.ok b/test/fail/ok/suggest-long-ai.tc.ok similarity index 99% rename from test/fail/ok/suggest-ai.tc.ok rename to test/fail/ok/suggest-long-ai.tc.ok index 4e734901185..7f50d74de08 100644 --- a/test/fail/ok/suggest-ai.tc.ok +++ b/test/fail/ok/suggest-long-ai.tc.ok @@ -1,4 +1,4 @@ -suggest-ai.mo:4.1-4.5: type error [M0072], field stableM does not exist in type: +suggest-long-ai.mo:4.1-4.5: type error [M0072], field stableM does not exist in type: module { type ErrorCode = { diff --git a/test/fail/ok/suggest-long-ai.tc.ret.ok b/test/fail/ok/suggest-long-ai.tc.ret.ok new file mode 100644 index 00000000000..69becfa16f9 --- /dev/null +++ b/test/fail/ok/suggest-long-ai.tc.ret.ok @@ -0,0 +1 @@ +Return code 1 diff --git a/test/fail/ok/suggest-short-ai.tc.ok b/test/fail/ok/suggest-short-ai.tc.ok new file mode 100644 index 00000000000..da8382a1215 --- /dev/null +++ b/test/fail/ok/suggest-short-ai.tc.ok @@ -0,0 +1,259 @@ +suggest-short-ai.mo:4.1-4.5: type error [M0072], field s does not exist in type: + module { + type ErrorCode = + { + #call_error : {err_code : Nat32}; + #canister_error; + #canister_reject; + #destination_invalid; + #future : Nat32; + #system_fatal; + #system_transient + }; + Array_init : (Nat, T) -> [var T]; + Array_tabulate : (Nat, Nat -> T) -> [T]; + Ret : () -> T; + Types : + module { + type Any = Any; + type Blob = Blob; + type Bool = Bool; + type Char = Char; + type Error = Error; + type Float = Float; + type Int = Int; + type Int16 = Int16; + type Int32 = Int32; + type Int64 = Int64; + type Int8 = Int8; + type Nat = Nat; + type Nat16 = Nat16; + type Nat32 = Nat32; + type Nat64 = Nat64; + type Nat8 = Nat8; + type None = None; + type Null = Null; + type Principal = Principal; + type Region = Region; + type Text = Text + }; + abs : Int -> Nat; + arccos : Float -> Float; + arcsin : Float -> Float; + arctan : Float -> Float; + arctan2 : (Float, Float) -> Float; + arrayMutToBlob : [var Nat8] -> Blob; + arrayToBlob : [Nat8] -> Blob; + blobCompare : (Blob, Blob) -> Int8; + blobOfPrincipal : Principal -> Blob; + blobToArray : Blob -> [Nat8]; + blobToArrayMut : Blob -> [var Nat8]; + btstInt16 : (Int16, Int16) -> Bool; + btstInt32 : (Int32, Int32) -> Bool; + btstInt64 : (Int64, Int64) -> Bool; + btstInt8 : (Int8, Int8) -> Bool; + btstNat16 : (Nat16, Nat16) -> Bool; + btstNat32 : (Nat32, Nat32) -> Bool; + btstNat64 : (Nat64, Nat64) -> Bool; + btstNat8 : (Nat8, Nat8) -> Bool; + call_raw : (Principal, Text, Blob) -> async Blob; + cancelTimer : Nat -> (); + canisterVersion : () -> Nat64; + charIsAlphabetic : Char -> Bool; + charIsLowercase : Char -> Bool; + charIsUppercase : Char -> Bool; + charIsWhitespace : Char -> Bool; + charToLower : Char -> Char; + charToNat32 : Char -> Nat32; + charToText : Char -> Text; + charToUpper : Char -> Char; + clzInt16 : Int16 -> Int16; + clzInt32 : Int32 -> Int32; + clzInt64 : Int64 -> Int64; + clzInt8 : Int8 -> Int8; + clzNat16 : Nat16 -> Nat16; + clzNat32 : Nat32 -> Nat32; + clzNat64 : Nat64 -> Nat64; + clzNat8 : Nat8 -> Nat8; + cos : Float -> Float; + createActor : (Blob, Blob) -> async Principal; + ctzInt16 : Int16 -> Int16; + ctzInt32 : Int32 -> Int32; + ctzInt64 : Int64 -> Int64; + ctzInt8 : Int8 -> Int8; + ctzNat16 : Nat16 -> Nat16; + ctzNat32 : Nat32 -> Nat32; + ctzNat64 : Nat64 -> Nat64; + ctzNat8 : Nat8 -> Nat8; + cyclesAccept : Nat -> Nat; + cyclesAdd : Nat -> (); + cyclesAvailable : () -> Nat; + cyclesBalance : () -> Nat; + cyclesBurn : Nat -> Nat; + cyclesRefunded : () -> Nat; + debugPrint : Text -> (); + debugPrintChar : Char -> (); + debugPrintInt : Int -> (); + debugPrintNat : Nat -> (); + decodeUtf8 : Blob -> ?Text; + encodeUtf8 : Text -> Blob; + error : Text -> Error; + errorCode : Error -> ErrorCode; + errorMessage : Error -> Text; + exists : (T -> Bool) -> Bool; + exp : Float -> Float; + floatAbs : Float -> Float; + floatCeil : Float -> Float; + floatCopySign : (Float, Float) -> Float; + floatFloor : Float -> Float; + floatMax : (Float, Float) -> Float; + floatMin : (Float, Float) -> Float; + floatNearest : Float -> Float; + floatSqrt : Float -> Float; + floatToFormattedText : (Float, Nat8, Nat8) -> Text; + floatToInt : Float -> Int; + floatToInt64 : Float -> Int64; + floatToText : Float -> Text; + floatTrunc : Float -> Float; + forall : (T -> Bool) -> Bool; + getCandidLimits : + () -> {bias : Nat32; denominator : Nat32; numerator : Nat32}; + getCertificate : () -> ?Blob; + hashBlob : Blob -> Nat32; + idlHash : Text -> Nat32; + int16ToInt : Int16 -> Int; + int16ToInt32 : Int16 -> Int32; + int16ToInt8 : Int16 -> Int8; + int16ToNat16 : Int16 -> Nat16; + int32ToInt : Int32 -> Int; + int32ToInt16 : Int32 -> Int16; + int32ToInt64 : Int32 -> Int64; + int32ToNat32 : Int32 -> Nat32; + int64ToFloat : Int64 -> Float; + int64ToInt : Int64 -> Int; + int64ToInt32 : Int64 -> Int32; + int64ToNat64 : Int64 -> Nat64; + int8ToInt : Int8 -> Int; + int8ToInt16 : Int8 -> Int16; + int8ToNat8 : Int8 -> Nat8; + intToFloat : Int -> Float; + intToInt16 : Int -> Int16; + intToInt16Wrap : Int -> Int16; + intToInt32 : Int -> Int32; + intToInt32Wrap : Int -> Int32; + intToInt64 : Int -> Int64; + intToInt64Wrap : Int -> Int64; + intToInt8 : Int -> Int8; + intToInt8Wrap : Int -> Int8; + intToNat16Wrap : Int -> Nat16; + intToNat32Wrap : Int -> Nat32; + intToNat64Wrap : Int -> Nat64; + intToNat8Wrap : Int -> Nat8; + isController : Principal -> Bool; + log : Float -> Float; + nat16ToInt16 : Nat16 -> Int16; + nat16ToNat : Nat16 -> Nat; + nat16ToNat32 : Nat16 -> Nat32; + nat16ToNat8 : Nat16 -> Nat8; + nat32ToChar : Nat32 -> Char; + nat32ToInt32 : Nat32 -> Int32; + nat32ToNat : Nat32 -> Nat; + nat32ToNat16 : Nat32 -> Nat16; + nat32ToNat64 : Nat32 -> Nat64; + nat64ToInt64 : Nat64 -> Int64; + nat64ToNat : Nat64 -> Nat; + nat64ToNat32 : Nat64 -> Nat32; + nat8ToInt8 : Nat8 -> Int8; + nat8ToNat : Nat8 -> Nat; + nat8ToNat16 : Nat8 -> Nat16; + natToNat16 : Nat -> Nat16; + natToNat32 : Nat -> Nat32; + natToNat64 : Nat -> Nat64; + natToNat8 : Nat -> Nat8; + performanceCounter : Nat32 -> Nat64; + popcntInt16 : Int16 -> Int16; + popcntInt32 : Int32 -> Int32; + popcntInt64 : Int64 -> Int64; + popcntInt8 : Int8 -> Int8; + popcntNat16 : Nat16 -> Nat16; + popcntNat32 : Nat32 -> Nat32; + popcntNat64 : Nat64 -> Nat64; + popcntNat8 : Nat8 -> Nat8; + principalOfActor : (actor {}) -> Principal; + principalOfBlob : Blob -> Principal; + regionGrow : (Region, Nat64) -> Nat64; + regionId : Region -> Nat; + regionLoadBlob : (Region, Nat64, Nat) -> Blob; + regionLoadFloat : (Region, Nat64) -> Float; + regionLoadInt16 : (Region, Nat64) -> Int16; + regionLoadInt32 : (Region, Nat64) -> Int32; + regionLoadInt64 : (Region, Nat64) -> Int64; + regionLoadInt8 : (Region, Nat64) -> Int8; + regionLoadNat16 : (Region, Nat64) -> Nat16; + regionLoadNat32 : (Region, Nat64) -> Nat32; + regionLoadNat64 : (Region, Nat64) -> Nat64; + regionLoadNat8 : (Region, Nat64) -> Nat8; + regionNew : () -> Region; + regionSize : Region -> Nat64; + regionStoreBlob : (Region, Nat64, Blob) -> (); + regionStoreFloat : (Region, Nat64, Float) -> (); + regionStoreInt16 : (Region, Nat64, Int16) -> (); + regionStoreInt32 : (Region, Nat64, Int32) -> (); + regionStoreInt64 : (Region, Nat64, Int64) -> (); + regionStoreInt8 : (Region, Nat64, Int8) -> (); + regionStoreNat16 : (Region, Nat64, Nat16) -> (); + regionStoreNat32 : (Region, Nat64, Nat32) -> (); + regionStoreNat64 : (Region, Nat64, Nat64) -> (); + regionStoreNat8 : (Region, Nat64, Nat8) -> (); + rts_callback_table_count : () -> Nat; + rts_callback_table_size : () -> Nat; + rts_collector_instructions : () -> Nat; + rts_heap_size : () -> Nat; + rts_logical_stable_memory_size : () -> Nat; + rts_max_live_size : () -> Nat; + rts_max_stack_size : () -> Nat; + rts_memory_size : () -> Nat; + rts_mutator_instructions : () -> Nat; + rts_reclaimed : () -> Nat; + rts_stable_memory_size : () -> Nat; + rts_total_allocation : () -> Nat; + rts_upgrade_instructions : () -> Nat; + rts_version : () -> Text; + setCandidLimits : + {bias : Nat32; denominator : Nat32; numerator : Nat32} -> (); + setCertifiedData : Blob -> (); + setTimer : (Nat64, Bool, () -> async ()) -> Nat; + shiftLeft : (Nat, Nat32) -> Nat; + shiftRight : (Nat, Nat32) -> Nat; + sin : Float -> Float; + stableMemoryGrow : Nat64 -> Nat64; + stableMemoryLoadBlob : (Nat64, Nat) -> Blob; + stableMemoryLoadFloat : Nat64 -> Float; + stableMemoryLoadInt16 : Nat64 -> Int16; + stableMemoryLoadInt32 : Nat64 -> Int32; + stableMemoryLoadInt64 : Nat64 -> Int64; + stableMemoryLoadInt8 : Nat64 -> Int8; + stableMemoryLoadNat16 : Nat64 -> Nat16; + stableMemoryLoadNat32 : Nat64 -> Nat32; + stableMemoryLoadNat64 : Nat64 -> Nat64; + stableMemoryLoadNat8 : Nat64 -> Nat8; + stableMemorySize : () -> Nat64; + stableMemoryStoreBlob : (Nat64, Blob) -> (); + stableMemoryStoreFloat : (Nat64, Float) -> (); + stableMemoryStoreInt16 : (Nat64, Int16) -> (); + stableMemoryStoreInt32 : (Nat64, Int32) -> (); + stableMemoryStoreInt64 : (Nat64, Int64) -> (); + stableMemoryStoreInt8 : (Nat64, Int8) -> (); + stableMemoryStoreNat16 : (Nat64, Nat16) -> (); + stableMemoryStoreNat32 : (Nat64, Nat32) -> (); + stableMemoryStoreNat64 : (Nat64, Nat64) -> (); + stableMemoryStoreNat8 : (Nat64, Nat8) -> (); + stableVarQuery : () -> shared query () -> async {size : Nat64}; + tan : Float -> Float; + textCompare : (Text, Text) -> Int8; + textLowercase : Text -> Text; + textUppercase : Text -> Text; + time : () -> Nat64; + trap : Text -> None + } +The field s is not available. Try something else? diff --git a/test/fail/ok/suggest-short-ai.tc.ret.ok b/test/fail/ok/suggest-short-ai.tc.ret.ok new file mode 100644 index 00000000000..69becfa16f9 --- /dev/null +++ b/test/fail/ok/suggest-short-ai.tc.ret.ok @@ -0,0 +1 @@ +Return code 1 diff --git a/test/fail/ok/suggest-type-ai.tc.ok b/test/fail/ok/suggest-type-ai.tc.ok new file mode 100644 index 00000000000..6735a8a3042 --- /dev/null +++ b/test/fail/ok/suggest-type-ai.tc.ok @@ -0,0 +1,25 @@ +suggest-type-ai.mo:4.21-4.24: type error [M0030], type field Num does not exist in type + module { + type Any = Any; + type Blob = Blob; + type Bool = Bool; + type Char = Char; + type Error = Error; + type Float = Float; + type Int = Int; + type Int16 = Int16; + type Int32 = Int32; + type Int64 = Int64; + type Int8 = Int8; + type Nat = Nat; + type Nat16 = Nat16; + type Nat32 = Nat32; + type Nat64 = Nat64; + type Nat8 = Nat8; + type None = None; + type Null = Null; + type Principal = Principal; + type Region = Region; + type Text = Text + } +The type field Num is not available. Try something else? diff --git a/test/fail/ok/suggest-type-ai.tc.ret.ok b/test/fail/ok/suggest-type-ai.tc.ret.ok new file mode 100644 index 00000000000..69becfa16f9 --- /dev/null +++ b/test/fail/ok/suggest-type-ai.tc.ret.ok @@ -0,0 +1 @@ +Return code 1 diff --git a/test/fail/suggest-label-ai.mo b/test/fail/suggest-label-ai.mo new file mode 100644 index 00000000000..1693da5a3ca --- /dev/null +++ b/test/fail/suggest-label-ai.mo @@ -0,0 +1,4 @@ +//MOC-FLAG --ai-errors +label foo { + break fo; +}; diff --git a/test/fail/suggest-local-ai.mo b/test/fail/suggest-local-ai.mo new file mode 100644 index 00000000000..462353bd86e --- /dev/null +++ b/test/fail/suggest-local-ai.mo @@ -0,0 +1,3 @@ +//MOC-FLAG --ai-errors +let xxx = 1; +x; diff --git a/test/fail/suggest-local-type-ai.mo b/test/fail/suggest-local-type-ai.mo new file mode 100644 index 00000000000..ebfb4018f26 --- /dev/null +++ b/test/fail/suggest-local-type-ai.mo @@ -0,0 +1,3 @@ +//MOC-FLAG --ai-errors +type Foo = Int; +type Zap = [Fo]; diff --git a/test/fail/suggest-long-ai.mo b/test/fail/suggest-long-ai.mo new file mode 100644 index 00000000000..9666b3dd3b4 --- /dev/null +++ b/test/fail/suggest-long-ai.mo @@ -0,0 +1,4 @@ +//MOC-FLAG --ai-errors +import Prim "mo:⛔"; + +Prim.stableM; diff --git a/test/fail/suggest-short-ai.mo b/test/fail/suggest-short-ai.mo new file mode 100644 index 00000000000..0b557e72929 --- /dev/null +++ b/test/fail/suggest-short-ai.mo @@ -0,0 +1,4 @@ +//MOC-FLAG --ai-errors +import Prim "mo:⛔"; + +Prim.s; diff --git a/test/fail/suggest-type-ai.mo b/test/fail/suggest-type-ai.mo new file mode 100644 index 00000000000..c43e3f30bda --- /dev/null +++ b/test/fail/suggest-type-ai.mo @@ -0,0 +1,4 @@ +//MOC-FLAG --ai-errors +import Prim "mo:⛔"; + +type T = Prim.Types.Num;