Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
136469c
feat: add modifiers and single inheritance
Th0rgal Aug 9, 2026
30475c4
fix: address inheritance review findings
Th0rgal Aug 9, 2026
960633d
fix: harden inherited constructor and overload composition
Th0rgal Aug 9, 2026
43b0356
fix: close inheritance review gaps
Th0rgal Aug 9, 2026
bf64c4f
fix: enforce inherited scope and ABI compatibility
Th0rgal Aug 9, 2026
c5aa4c9
fix: complete inherited binding and property handling
Th0rgal Aug 9, 2026
ce1a176
fix: harden inherited property parsing
Th0rgal Aug 9, 2026
67b6169
fix: fail closed in inheritance property parsing
Th0rgal Aug 9, 2026
baf9ad1
fix: reject ambiguous qualified property parents
Th0rgal Aug 9, 2026
c39e4be
fix: reject duplicate property contract names
Th0rgal Aug 9, 2026
65e9e2f
fix: qualify generated property parents
Th0rgal Aug 9, 2026
1cfce3f
fix: validate inherited role identities
Th0rgal Aug 9, 2026
55d7a73
fix: resolve inherited role fields
Th0rgal Aug 9, 2026
4adcc67
fix: close inheritance review gaps
Th0rgal Aug 9, 2026
30ad7a1
test: sync inheritance property stubs
Th0rgal Aug 9, 2026
4cb42aa
fix: persist inheritance metadata across imports
Th0rgal Aug 9, 2026
e11c684
fix: type-check inherited constructor arguments
Th0rgal Aug 9, 2026
c189b97
test: sync narrow constructor property stub
Th0rgal Aug 9, 2026
d6451ab
fix: preserve virtual overrides across inheritance
Th0rgal Aug 9, 2026
6648151
fix: reserve tuple parameter aliases
Th0rgal Aug 9, 2026
cec5e53
fix: support inherited marker interfaces
Th0rgal Aug 9, 2026
f2387cf
fix: close inheritance review gaps
Th0rgal Aug 9, 2026
6f3dd69
fix: preserve inherited type identities
Th0rgal Aug 10, 2026
db122c2
fix inherited constructor and property regressions
Th0rgal Aug 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
497 changes: 497 additions & 0 deletions Contracts/Smoke/Helpers.lean

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions Contracts/Smoke/InheritanceImportBase.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Contracts.Common

namespace Contracts.Smoke.InheritanceImport

open Contracts
open Verity hiding pure bind

verity_contract ImportedInheritanceBase where
types
ImportedAmount : Uint256
storage
inheritedValue : Uint256 := slot 0

end Contracts.Smoke.InheritanceImport
20 changes: 20 additions & 0 deletions Contracts/Smoke/InheritanceImportChild.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Contracts.Smoke.InheritanceImportBase
import Compiler.CheckContract

namespace Contracts.Smoke.InheritanceImport

open Contracts
open Verity hiding pure bind

-- The parent is loaded exclusively from InheritanceImportBase.olean. This
-- fails if inheritance metadata is held in process-local state.
verity_contract ImportedInheritanceChild is ImportedInheritanceBase where
storage
childValue : Uint256 := slot 1

function setImported (next : ImportedAmount) : Unit := do
setStorage inheritedValue next

#check_contract ImportedInheritanceChild

end Contracts.Smoke.InheritanceImport
3 changes: 3 additions & 0 deletions Verity/Macro/Elaborate.lean
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def elabVerityContract : CommandElab := fun stx => do
validateExternalDeclsPublic externalDecls
validateFunctionDeclsPublic fields errorDecls constDecls immutableDecls externalDecls ctor modifiers functions

let declarationNs ← getCurrNamespace
elabCommand (← `(namespace $contractName))
try
for constant in constDecls do
Expand Down Expand Up @@ -149,6 +150,8 @@ def elabVerityContract : CommandElab := fun stx => do
if fn.isPure then
elabCommand (← mkPureTheoremCommand fn)

registerContractSyntax (declarationNs ++ contractName.getId) parsed

-- Emit per-function _no_calls theorems for no_external_calls functions (#1729, Axis 3 Step 1c).
for fn in functions do
if fn.noExternalCalls then
Expand Down
2 changes: 0 additions & 2 deletions Verity/Macro/Interfaces.lean
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ def parseInterface
match stx with
| `(verityInterface| interface $name:ident where $[$fns:verityInterfaceFunction]* end) =>
let parsedFns ← fns.mapM (parseInterfaceFunction newtypes structDecls adtDecls)
if parsedFns.isEmpty then
throwErrorAt name s!"interface '{toString name.getId}' must declare at least one function"
pure { ident := name, name := toString name.getId, functions := parsedFns }
| _ => throwErrorAt stx "invalid interface declaration"

Expand Down
11 changes: 7 additions & 4 deletions Verity/Macro/Syntax.lean
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ declare_syntax_cat verityNamespaceSpec
declare_syntax_cat veritySpecialEntrypoint
declare_syntax_cat verityModifier
declare_syntax_cat verityModifierUse
declare_syntax_cat verityDispatch
declare_syntax_cat verityRoleDecl
declare_syntax_cat verityFunction
declare_syntax_cat verityIntrinsicClause
Expand Down Expand Up @@ -96,6 +97,8 @@ syntax "allow_post_interaction_writes" : verityMutability
syntax "nonreentrant(" ident ")" : verityMutability
syntax "cei_safe" : verityMutability
syntax "reentrancy_trusted" : verityMutability
syntax "virtual" : verityDispatch
syntax "override" : verityDispatch
syntax "modifies(" sepBy1(ident, ",") ")" : verityModifies
syntax "requires(" ident ")" : verityRequiresRole
syntax ident " : " term:max : verityNewtype
Expand Down Expand Up @@ -151,14 +154,14 @@ syntax "requireError " term:max ppSpace ident "(" sepBy(term, ",") ")" : doElem
syntax (name := requireSomeUintErrorTerm) "requireSomeUintError " term:max ppSpace ident "(" sepBy(term, ",") ")" : term
syntax "ecmBind " term:max ppSpace term:max ppSpace term:max : doElem
syntax (priority := high) "unsafe " str " do " doSeq : doElem
syntax "constructor " "(" sepBy(verityParam, ",") ")" (ppSpace verityLocalObligations)? " := " term : verityConstructor
syntax "constructor " "(" sepBy(verityParam, ",") ")" " payable" (ppSpace verityLocalObligations)? " := " term : verityConstructor
syntax "constructor " "(" sepBy(verityParam, ",") ")" (ppSpace ident "(" sepBy(term, ",") ")")? (ppSpace verityLocalObligations)? " := " term : verityConstructor
syntax "constructor " "(" sepBy(verityParam, ",") ")" " payable" (ppSpace ident "(" sepBy(term, ",") ")")? (ppSpace verityLocalObligations)? " := " term : verityConstructor
syntax "receive" (ppSpace verityLocalObligations)? " := " term : veritySpecialEntrypoint
syntax "fallback" (ppSpace verityLocalObligations)? " := " term : veritySpecialEntrypoint
syntax "modifier " ident " := " term : verityModifier
syntax "with " sepBy1(ident, ",") : verityModifierUse
syntax ident " := " ident : verityRoleDecl
syntax "function " verityMutability* (pureMutabilityMarker)? verityMutability* ident " (" sepBy(verityParam, ",") ")" (ppSpace verityInitGuard)? (ppSpace verityModifierUse)? (ppSpace verityRequiresRole)? (ppSpace verityModifies)? (ppSpace verityLocalObligations)? " : " term " := " term : verityFunction
syntax "function " verityMutability* (pureMutabilityMarker)? verityMutability* verityDispatch* ident " (" sepBy(verityParam, ",") ")" (ppSpace verityInitGuard)? (ppSpace verityModifierUse)? (ppSpace verityRequiresRole)? (ppSpace verityModifies)? (ppSpace verityLocalObligations)? " : " term " := " term : verityFunction

-- verity_intrinsic syntax (minimal one-argument shape for consumer-owned intrinsics)
-- `pure` is parsed as an identifier here to avoid reserving it as a global
Expand Down Expand Up @@ -190,7 +193,7 @@ syntax (name := verityIntrinsicCmd)
ident " := " term ";" ident "[" sepBy(verityIntrinsicObligation, ",") "]" : command

syntax (name := verityContractCmd)
"verity_contract " ident " where "
"verity_contract " ident (" is " ident)? " where "
("types " verityNewtype+)?
("inductive " verityAdtDecl+)?
(verityNamespaceSpec)?
Expand Down
Loading
Loading