Skip to content

Commit

Permalink
move M0200 error detection from compile.ml to typing.ml, using special
Browse files Browse the repository at this point in the history
  • Loading branch information
crusso authored Jun 28, 2024
1 parent 74c5809 commit d18df6d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/codegen/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11253,10 +11253,7 @@ and compile_prim_invocation (env : E.t) ae p es at =
E.call_import env "rts" "log" (* musl *)

| OtherPrim "componentCall", [e] ->
if not !Flags.import_component then (
Printf.printf "%s" (Diag.string_of_message (
Diag.error_message at "M0200" "import" (Printf.sprintf "component import is unavailable (pass `-import-component` flag)")));
exit 1);
assert !Flags.import_component;
SR.UnboxedWord32 Type.Nat32,
compile_exp_as env ae (SR.UnboxedWord32 Type.Nat32) e ^^
E.call_import env "component" "call"
Expand Down
5 changes: 4 additions & 1 deletion src/mo_frontend/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ let check_deprecation env at desc id depr =
| _ -> fun _ _ _ _ -> ())
env at code
"this code is (or uses) the deprecated library `ExperimentalStableMemory`.\nPlease use the `Region` library instead: https://internetcomputer.org/docs/current/motoko/main/stable-memory/stable-regions/#the-region-library or compile with flag `--experimental-stable-memory 1` to suppress this message."
end
end
| Some ("M0200" as code) ->
if not !Flags.import_component then
error env at code "component import is unavailable (pass `-import-component` flag)"
| Some msg ->
warn env at "M0154" "%s %s is deprecated:\n%s" desc id msg
| None -> ()
Expand Down
1 change: 1 addition & 0 deletions src/prelude/prim.mo
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ func log(f : Float) : Float = (prim "flog" : Float -> Float) f;
// Wasm component model functions
/// @deprecated M0200
func componentCall(n : Nat32) : Nat32 = (prim "componentCall" : Nat32 -> Nat32) n;
// Array utilities
Expand Down
2 changes: 1 addition & 1 deletion test/fail/ok/M0200.tc.ok
Original file line number Diff line number Diff line change
@@ -1 +1 @@
M0200.mo:3.8-3.28: import error [M0200], component import is unavailable (pass `-import-component` flag)
M0200.mo:3.8-3.23: type error [M0200], component import is unavailable (pass `-import-component` flag)
1 change: 1 addition & 0 deletions test/fail/ok/no-timer-canc.tc.ok
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ no-timer-canc.mo:3.10-3.21: type error [M0119], object field cancelTimer is not
clzNat32 : Nat32 -> Nat32;
clzNat64 : Nat64 -> Nat64;
clzNat8 : Nat8 -> Nat8;
componentCall : Nat32 -> Nat32;
cos : Float -> Float;
createActor : (Blob, Blob) -> async Principal;
ctzInt16 : Int16 -> Int16;
Expand Down
1 change: 1 addition & 0 deletions test/fail/ok/no-timer-set.tc.ok
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ no-timer-set.mo:3.10-3.18: type error [M0119], object field setTimer is not cont
clzNat32 : Nat32 -> Nat32;
clzNat64 : Nat64 -> Nat64;
clzNat8 : Nat8 -> Nat8;
componentCall : Nat32 -> Nat32;
cos : Float -> Float;
createActor : (Blob, Blob) -> async Principal;
ctzInt16 : Int16 -> Int16;
Expand Down

0 comments on commit d18df6d

Please sign in to comment.