Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
* various fixes
* the beginnings of a type-based alias analysis
* ...
  • Loading branch information
zerbina committed Sep 16, 2024
1 parent ca893cd commit d5c8afd
Show file tree
Hide file tree
Showing 6 changed files with 396 additions and 52 deletions.
2 changes: 2 additions & 0 deletions compiler/ast/report_enums.nim
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ type
rsemCannotBorrowImmutable
rsemCannotBorrow2
rsemMustBeConstructor
rsemOverlappingParamBorrows
rsemPotentialAliasViolation

rsemCyclicTree
rsemCyclicDependency
Expand Down
2 changes: 1 addition & 1 deletion compiler/ast/reports_sem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ type
of rsemDiagnostics:
diag*: SemDiagnostics

of rsemIllegalBorrow:
of rsemIllegalBorrow, rsemOverlappingParamBorrows:
borrow*: PNode
isProblemMutation*: bool
problem*, usage*: TLineInfo
Expand Down
9 changes: 9 additions & 0 deletions compiler/front/cli_reporter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,15 @@ proc reportBody*(conf: ConfigRef, r: SemReport): string =
result.add "cannot borrow from expression: " & $r.ast
of rsemMustBeConstructor:
result.add "RHS of compound view assignment must be constructor expression"
of rsemOverlappingParamBorrows:
if r.isProblemMutation:
result.add "cannot create another mutable borrow\n"
result.add "$1 another, potentially overlapping, mutable borrow was created here" % [conf.toStr(r.usage)]
else:
result.add "cannot create mutable borrow\n"
result.add "$1 a potentially overlapping immutable borrow was created here" % [conf.toStr(r.usage)]
of rsemPotentialAliasViolation:
result.add "cannot create borrow because the location could be modified through '$1'" % [$r.ast]

of rsemPragmaRecursiveDependency:
result.add "recursive dependency: "
Expand Down
Loading

0 comments on commit d5c8afd

Please sign in to comment.