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
- Severity:
Error(Fatal Compile-Time Conservation Failure) - Named In: Part 3: Question The Rules: The Birth of Fin# (
books/aubrie/e007/c001/p003.md) - Cause: Code attempted to mutate an
Account<K, T>via scalar assignment (=,+=,-=), conjure an unpairedCapital<T>literal outside a boundary/credit leg, or mutate ledger state outside an atomictransactionblock.
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
- Severity:
Error - Cause: Inside a
transactionblock, the symbolic or concrete sum ofdebitpostings does not equal the sum ofcreditpostings for one or more currencies (∑ Debits ≠ ∑ Credits).
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
- Severity:
Error - Cause: An IEEE 754 binary floating-point type (
float/Singleordouble/Double) was passed to or combined withCapital<T>,Rate<A, B>, orAccount<K, T>.
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
- Severity:
Error - Cause: Two
Capital<T>orAccount<K, T>operands with different ISO 4217 currency type arguments (such asCapital<USD>andCapital<EUR>) were combined directly without an auditablefx.convert(...)clearing bridge.
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
- Severity:
Error - Cause: A variable or tuple element of linear type
Capital<T>(most commonly theremainderelement returned bycapital.splitEqual) reached the end of a lexical scope or conditional branch without being consumed by adebitposting orcapital.*combinator.
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.