dfinity / prettier-plugin-motoko

A code formatter for the Motoko smart contract language.
Apache License 2.0
28 stars 1 forks source link

syntax error #119

Closed Kranthi-Sai closed 1 year ago

Kranthi-Sai commented 1 year ago

import Debug "mo:base/Debug"; import List "mo:base/List"; import Text "mo:base/Text"; import Nat "mo:base/Nat";

actor UserDatabase { public type UserData = { userId : Text; earnPoints : Nat; }; stable var userd : List.List = List.nil();

public func saveUser(userDataText : Text, earnPointsNat : Nat) { let newUser : UserData = { userId = userDataText; earnPoints = earnPointsNat; };

userd := List.push(newUser, userd);
Debug.print(debug_show (userd));

};

public query func read() : async [UserData] { return List.toArray(userd); };

public func deleteUser(userIdToDelete: Text) { let newUserd = List.filter((user) => user.userId != userIdToDelete, userd); userd := newUserd; Debug.print("User deleted with userId: " # userIdToDelete); };

}; error: Error [M0001] in file Main.mo:27:36 unexpected token '=', expected one of token or sequence: ) . ! <exp_nullary(ob)> <exp(ob)> |> <exp_bin(ob)> or <exp_bin(ob)> <exp(ob)> implies <exp_bin(ob)> <exp_bin(ob)> . , seplist(<exp(ob)>,,) : <exp_bin(ob)> <exp(ob)> and <exp_bin(ob)> <exp_bin(ob)> <exp_nullary(ob)> [ <exp(ob)> ]