PromptECO / clariform

Linter & formatter for Clarity
Eclipse Public License 2.0
13 stars 2 forks source link

Invalid or misplaced code on line xyz - Parse error? #20

Open moodmosaic opened 1 year ago

moodmosaic commented 1 year ago

Getting weird output with the following contract:

docker run ghcr.io/njordhov/clariform --version
0.4.0

docker run ghcr.io/njordhov/clariform \
"https://raw.githubusercontent.com/kenrogers/cargo/cf56971900c62fc1058e942fc48186dee90c4063/contracts/cargo.clar"
Invalid or misplaced code on line 28: (
Invalid or misplaced code on line 29: (
Invalid or misplaced code on line 38: (
Invalid or misplaced code on line 38: "
;; cargo
;; a simple decentralized shipment tracker

;; constants
(define-constant err-shipment-not-found (err u100))
(define-constant err-tx-sender-unauthorized (err u101))

;; data maps and vars
(define-data-var last-shipment-id uint u0)
(define-map shipments uint {location: (string-ascii 25), status: (string-ascii 25), shipper: principal, receiver: principal})

;; private functions
;;

;; public functions
(define-public (create-new-shipment (starting-location (string-ascii 25)) (receiver principal))
    (let
        (   (new-shipment-id (+ (var-get last-shipment-id) u1)))
        ;; #[filter(starting-location, receiver)]
        (map-set shipments new-shipment-id {location: starting-location, status: "In Transit", shipper: tx-sender, receiver: receiver})
        (ok "Shipment created successfully")))

[:invalid "("]

define-public (update-shipment (shipment-id uint) (current-location (string-ascii 25)))
    [:invalid "("]

let
    (   (previous-shipment (unwrap! (map-get? shipments shipment-id) err-shipment-not-found))
        (shipper (get shipper previous-shipment))
        (new-shipment-info (merge previous-shipment {location: current-location})))
    (asserts! (is-eq tx-sender shipper) err-tx-sender-unauthorized)
        ;; #[filter(shipment-id)]
    (map-set shipments shipment-id new-shipment-info)
    [:invalid "("]

ok [:invalid "\""]

Sh

Invalid or misplaced code on line 1: "
Invalid or misplaced code on line 1: )
Invalid or misplaced code on line 2: )
Invalid or misplaced code on line 3: )
ipment updated successfully

[:invalid "\""]

[:invalid ")"]
[:invalid ")"]
[:invalid ")"]

;; read only functions
(define-read-only (get-shipment (shipment-id uint))
    (ok (unwrap! (map-get? shipments shipment-id) err-shipment-not-found)))