Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace panic("not reachable") with panic(NewUnreachableError()) #512

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion array.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ func (a *Array) Storable(_ SlabStorage, _ Address, maxInlineSize uint64) (Storab
return SlabIDStorable(a.SlabID()), nil

default:
panic("not reachable")
panic(NewUnreachableError())
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/smoke/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func modifyArray(
case arrayMutateChildContainerAfterAppend:
nextNestedLevels = nestedLevels - 1
default:
panic("not reachable")
panic(atree.NewUnreachableError())
}

// Create new chid child
Expand Down Expand Up @@ -366,7 +366,7 @@ func modifyArray(
case arrayMutateChildContainerAfterSet:
nextNestedLevels = nestedLevels - 1
default:
panic("not reachable")
panic(atree.NewUnreachableError())
}

// Create new child child
Expand Down Expand Up @@ -425,7 +425,7 @@ func modifyArray(
case arrayMutateChildContainerAfterInsert:
nextNestedLevels = nestedLevels - 1
default:
panic("not reachable")
panic(atree.NewUnreachableError())
}

// Create new child child
Expand Down
3 changes: 2 additions & 1 deletion cmd/smoke/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ func main() {
var err error
seed, err = strconv.ParseInt(strings.ReplaceAll(flagSeedHex, "0x", ""), 16, 64)
if err != nil {
panic("Failed to parse seed flag (hex string)")
fmt.Fprintf(os.Stderr, "failed to parse seed flag (hex string) %s: %s", flagSeedHex, err)
return
}
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/smoke/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func modifyMap(
case mapMutateChildContainerAfterSet:
nextNestedLevels = nestedLevels - 1
default:
panic("not reachable")
panic(atree.NewUnreachableError())
}

var expectedKey, key atree.Value
Expand Down Expand Up @@ -416,7 +416,7 @@ func modifyMap(

case mapRemoveOp:
if m.Type().IsComposite() {
panic("not reachable")
panic(atree.NewUnreachableError())
}

// Use for-range on Go map to get random key
Expand Down
2 changes: 1 addition & 1 deletion cmd/smoke/typeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func newCompositeTypeInfo() compositeTypeInfo {

endIndex := startIndex + count
if endIndex > len(compositeFieldNames) {
panic("not reachable")
panic(atree.NewUnreachableError())
}

return compositeTypeInfo{fieldStartIndex: startIndex, fieldEndIndex: endIndex}
Expand Down
2 changes: 1 addition & 1 deletion map.go
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ func (m *OrderedMap) Storable(_ SlabStorage, _ Address, maxInlineSize uint64) (S
return SlabIDStorable(m.SlabID()), nil

default:
panic("not reachable")
panic(NewUnreachableError())
}
}

Expand Down
6 changes: 3 additions & 3 deletions test_utils/expected_value_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ExpectedArrayValue []atree.Value
var _ atree.Value = &ExpectedArrayValue{}

func (v ExpectedArrayValue) Storable(atree.SlabStorage, atree.Address, uint64) (atree.Storable, error) {
panic("not reachable")
panic(atree.NewUnreachableError())
}

// ExpectedMapValue
Expand All @@ -42,7 +42,7 @@ type ExpectedMapValue map[atree.Value]atree.Value
var _ atree.Value = &ExpectedMapValue{}

func (v ExpectedMapValue) Storable(atree.SlabStorage, atree.Address, uint64) (atree.Storable, error) {
panic("not reachable")
panic(atree.NewUnreachableError())
}

// ExpectedWrapperValue
Expand All @@ -58,7 +58,7 @@ func NewExpectedWrapperValue(value atree.Value) ExpectedWrapperValue {
}

func (v ExpectedWrapperValue) Storable(atree.SlabStorage, atree.Address, uint64) (atree.Storable, error) {
panic("not reachable")
panic(atree.NewUnreachableError())
}

func ValueEqual(expected atree.Value, actual atree.Value) (bool, error) {
Expand Down
Loading