Fin# (Financial Sharp) v0.1.0
Browse Table of Contents (6 chapters)
Getting Started (2)
Language Specification (2)
Compiler & Standard Library (1)
Diagnostics & Proofs (1)
Master Symbol Index
3 min read Module: raggiesoft.finsharp F1: IDH_FIN_DIAGNOSTICS (0x3006)

Compiler Diagnostics Reference (FIN0001 – FIN0005)

Every conservation violation in Fin# is caught deterministically during finsc check and finsc build—long before code can touch a production database or ledger file. All diagnostics support --diagnostics=json and SARIF 2.1.0 output for CI/CD gates.


FIN0001: ConservationOfCapitalViolationException

Failing Example (FIN0001)

// ERROR FIN0001: Unpaired scalar mutation outside an atomic transaction!
// Capital cannot be created out of thin air without a counterparty credit leg.
OperatingRevenue += 500_000_000.00_USD;

Passing Fix

transaction RecordVerifiedEnergyDelivery [audit: Z_SOX_302, date: "2015-08-26"] {
    let settledReceivable : Capital<USD> = credit OperatingRevenue -> 500_000_000.00_USD;
    debit AccountsReceivable <- settledReceivable;
}

FIN0002: UnbalancedJournalEntryError

Failing Example (FIN0002)

transaction BrokenUtilitySplit [audit: Z_SOX_302] {
    let cash : Capital<USD> = credit OperatingChecking -> 120.00_USD;
    // Suppose a buggy custom helper tried to debit $125.00 against a $120.00 credit:
    debit ElectricUtilityExpense <- cash;
    debit InternetUtilityExpense <- credit OperatingChecking -> 5.00_USD; // Wait: if only one side posted -> FIN0002!
}

Passing Fix

Ensure every credit <Account> -> <Amount> leg is paired 1-for-1 (or via conservation-preserving capital.splitEqual / capital.combine combinators) with debit legs summing to the exact same Int128 scaled total.


FIN0003: BinaryFloatingPointForbiddenOnCapitalError

Failing Example (FIN0003)

let badTaxRate : float64 = 0.053; // IEEE 754 binary float!
// ERROR FIN0003: Binary floating-point is banned from touching Capital<USD>.
let taxAmount = subtotal * badTaxRate;

Passing Fix

Use exact 128-bit fixed-point BasisPoints / Fixed128 literals (5.30_pct or 530_bps) with an explicit RoundingPolicy so both the rounded tax share and sub-cent remainder are accounted for linearly!


FIN0004: CrossCurrencyConservationMismatchError

Failing Example (FIN0004)

// ERROR FIN0004: Cannot post Capital<SGD> into Account<Expense, USD>!
let sgdReceipt : Capital<SGD> = credit SingaporeCashWallet -> 42.00_SGD;
debit UsdDiningExpense <- sgdReceipt;

Passing Fix

Route sgdReceipt through fx.convert(sgdReceipt, quote, FxClearingBridge) so both the SGD and USD sub-ledgers remain independently balanced.


FIN0005: UnconsumedLinearCapitalError

Failing Example (FIN0005)

transaction DropPennyBug [audit: Z_SOX_302] {
    let dues : Capital<USD> = credit OperatingChecking -> 100.00_USD;
    // _ ignores the $0.01 remainder -> ERROR FIN0005!
    let (shares, _) = capital.splitEqual(dues, 3, RoundingPolicy.FloorWithRemainder);
    debit MemberA <- shares[0];
    debit MemberB <- shares[1];
    debit MemberC <- shares[2];
}

Passing Fix

Bind (shares, remainder) and explicitly post debit RoundingAdjustmentPool <- remainder; before closing the transaction block.

Indexed API Calls & Symbols on This Page (5):