Skip to content

Commit e79d0e2

Browse files
newm4nFerdinand Neman
andauthored
Salience over flow (#490)
* Increased some version stated in the docs to better reflect current version, and added documentation about NoopLogger logging for more neutral version of logging * Add some overflow protection when setting salience --------- Co-authored-by: Ferdinand Neman <[email protected]>
1 parent b976d16 commit e79d0e2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A clear and concise description of what the bug is.
1414
Steps to reproduce the behavior:
1515
1. I create code for this and that
1616
2. With a test for this and that
17-
3. Instead of seeng this
17+
3. Instead of seeing this
1818
4. I see that
1919

2020
**Expected behavior**

ast/Salience.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package ast
1616

17+
import "math"
18+
1719
// NewSalience create new Salience AST object
1820
func NewSalience(val int) *Salience {
1921

@@ -34,5 +36,9 @@ type SalienceReceiver interface {
3436

3537
// AcceptIntegerLiteral accept the assigned integer
3638
func (sal *Salience) AcceptIntegerLiteral(lit *IntegerLiteral) {
37-
sal.SalienceValue = int(lit.Integer)
39+
if lit.Integer >= math.MinInt32 && lit.Integer <= math.MaxInt32 {
40+
sal.SalienceValue = int(lit.Integer)
41+
} else {
42+
panic("Salience value out of range")
43+
}
3844
}

0 commit comments

Comments
 (0)