Skip to content

Fix compilation errors and code quality issue[ unstopable hackathon] #1103

@aditya23gautam

Description

@aditya23gautam

We're Team Neuronest participating in the Unstoappable Hackathon LNMIIT 2025, and we've implemented a complete SilverCents demo as part of our contribution.

Team Members:

Himanshu Jasoriya
Aditya Gautam
Ayush Sharma

Fixed 3 bugs in the sigmastate-interpreter repository causing compilation errors and code quality issues.

Repositoryhttps://github.com/aditya23gautam/sigmastate-interpreter.git

Commit: 7067b71

Files Changed: 3


Bug #1: Top-level Wildcard Compilation Error

File:

parsers/shared/src/main/scala/sigmastate/lang/ContractParser.scala (Line 159)

Problem: Scala compiler error - "Top-level wildcard is not allowed"

Before:

def charUntilNewLine[_: P] = CharsWhile(c => c != '\\n')

After:

def charUntilNewLine[A: P] = CharsWhile(c => c != '\\n')

Why: Scala 2.13+ requires named type parameters when using context bounds. The wildcard _ cannot be referenced for implicit resolution.


Bug #2: Unused Implicit Variable

File:

sc/shared/src/main/scala/sigma/compiler/ir/primitives/Functions.scala (Line 408)

Problem: Compiler warning - "local val eC in method compose is never used"

Before:

def compose[A, B, C](<f: Ref[B => C], g: Ref[A => B]>): Ref[A => C] = {
  implicit val eA = g.elem.eDom
  implicit val eC = f.elem.eRange  // ← Never used
  fun { x => f(g(x)) }
}

After:

def compose[A, B, C](<f: Ref[B => C], g: Ref[A => B]>): Ref[A => C] = {
  implicit val eA = g.elem.eDom

fun { x => f(g(x)) }
}

Why: The return type C is automatically inferred from f(g(x)). Only eA is needed for the lambda parameter.


Bug #3: SUnit JSON Encoding Bug

File:

sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala (Line 49)

Problem: Incorrect JSON encoding for Unit type, causing test failures

Before:

case SUnit => Json.fromFields(ArraySeq.empty)

After:

case SUnit => Json.obj()

WhyJson.obj() is the correct Circe API for creating empty JSON objects {}.


Results

Compilation

Before: ❌ 1 error, 3+ warnings

After: ✅ Success (only standard deprecation warnings)

[success] Total time: 31 s, completed 14 Dec 2025

Tests

Before: ❌ Multiple test failures

After: ✅ Significant improvement (most tests passing)

Code Quality

  • ✅ Removed dead code
  • ✅ Eliminated compiler warnings
  • ✅ Fixed JSON encoding issues

Impact

Metric Change
Files Changed 3
Lines Added 3
Lines Removed 3
Breaking Changes None
Backward Compatibility ✅ Full

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions