Skip to content

Commit

Permalink
sema: minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 14, 2025
1 parent 95f5bee commit c42e5d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 0 additions & 4 deletions std/jule/sema/sema.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2358,10 +2358,6 @@ impl sema {
// See developer reference (12.2.1).
s.Mutable = s.Mutable || (!f.Decl.Mutable && f.Type.Mutable())
s.Comparable = s.Comparable && f.Type.Comparable()
if s.Decl.Ident == "FuncTest" {
println(s.Mutable)
println(s.Comparable)
}

// Skip this field if not has default value.
if f.Decl.Default == nil {
Expand Down
9 changes: 5 additions & 4 deletions std/jule/sema/type.jule
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ struct typeChecker {
// If selection is a struct, returns invalid instance that only has decl field.
selection: bool

// Disabled type analysis flags.
disableTA: int

// See developer reference (4).
Expand Down Expand Up @@ -1554,7 +1555,7 @@ impl typeChecker {
ins.Generics = [&InsGeneric{Type: elem}]
_ = self.fromStructIns(ins, decl.Elem.Token)
}
if elem.Mutable() {
if self.disableTA&taMutable != taMutable && elem.Mutable() {
self.pushTA(taMutable)
}
ret &Chan{
Expand Down Expand Up @@ -1672,10 +1673,10 @@ impl typeChecker {
ret nil
}

if !elem.Comparable() {
if self.disableTA&taNotComparable != taNotComparable && !elem.Comparable() {
self.pushTA(taNotComparable)
}
if elem.Mutable() {
if self.disableTA&taMutable != taMutable && elem.Mutable() {
self.pushTA(taMutable)
}

Expand Down Expand Up @@ -1756,7 +1757,7 @@ impl typeChecker {
_ = self.fromStructIns(ins, decl.Key.Token)
}

if key.Mutable() || val.Mutable() {
if self.disableTA&taMutable != taMutable && (key.Mutable() || val.Mutable()) {
self.pushTA(taMutable)
}

Expand Down

0 comments on commit c42e5d1

Please sign in to comment.