Skip to content

Instantly share code, notes, and snippets.

@ukitaka
Created July 14, 2018 04:47
Show Gist options
  • Save ukitaka/c75906ff390f546d223d52fe8ded710f to your computer and use it in GitHub Desktop.
Save ukitaka/c75906ff390f546d223d52fe8ded710f to your computer and use it in GitHub Desktop.
swift -frontend -typecheck -debug-constraints test.swift
---Constraint solving for the expression at [test.swift:1:14 - line:1:14]---
---Initial constraints for the given expression---
(integer_literal_expr type='$T0' location=test.swift:1:14 range=[test.swift:1:14 - line:1:14] value=0)
Score: 0 0 0 0 0 0 0 0 0 0 0 0
Contextual Type: Int at [test.swift:1:8 - line:1:8]
Type Variables:
$T0 [inout allowed] literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int} @ locator@0x7faa21801000 [[email protected]:1:14]
Active Constraints:
Inactive Constraints:
$T0 literal conforms to ExpressibleByIntegerLiteral [[locator@0x7faa21801000 [[email protected]:1:14]]];
$T0 conv Int [[locator@0x7faa21801000 [[email protected]:1:14]]];
($T0 literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
Active bindings: $T0 := Int
(trying $T0 := Int
(found solution 0 0 0 0 0 0 0 0 0 0 0 0)
)
---Solution---
Fixed score: 0 0 0 0 0 0 0 0 0 0 0 0
Type variables:
$T0 as Int @ locator@0x7faa21801000 [[email protected]:1:14]
Overload choices:
Constraint restrictions:
Disjunction choices:
(found solution 0 0 0 0 0 0 0 0 0 0 0 0)
---Type-checked expression---
(call_expr implicit type='Int' location=test.swift:1:14 range=[test.swift:1:14 - line:1:14] arg_labels=_builtinIntegerLiteral:
(constructor_ref_call_expr implicit type='(_MaxBuiltinIntegerType) -> Int' location=test.swift:1:14 range=[test.swift:1:14 - line:1:14]
(declref_expr implicit type='(Int.Type) -> (_MaxBuiltinIntegerType) -> Int' location=test.swift:1:14 range=[test.swift:1:14 - line:1:14] decl=Swift.(file).Int.init(_builtinIntegerLiteral:) function_ref=single)
(type_expr implicit type='Int.Type' location=test.swift:1:14 range=[test.swift:1:14 - line:1:14] typerepr='Int'))
(tuple_expr implicit type='(_builtinIntegerLiteral: Int2048)' location=test.swift:1:14 range=[test.swift:1:14 - line:1:14] names=_builtinIntegerLiteral
(integer_literal_expr type='Int2048' location=test.swift:1:14 range=[test.swift:1:14 - line:1:14] value=0)))
---Constraint solving for the expression at [test.swift:2:15 - line:2:15]---
(overload set choice binding $T0 := Int)
(increasing score due to value to optional)
---Initial constraints for the given expression---
(declref_expr type='Int' location=test.swift:2:15 range=[test.swift:2:15 - line:2:15] decl=test.(file)[email protected]:1:5 direct_to_storage function_ref=unapplied)
Score: 0 0 0 0 0 0 0 1 0 0 0 0
Contextual Type: Int? at [test.swift:2:8 - line:2:11]
Type Variables:
$T0 [lvalue allowed] as Int @ locator@0x7faa21801000 [[email protected]:2:15]
Active Constraints:
Inactive Constraints:
Resolved overloads:
selected overload set choice a: $T0 == Int
(found solution 0 0 0 0 0 0 0 1 0 0 0 0)
---Solution---
Fixed score: 0 0 0 0 0 0 0 1 0 0 0 0
Type variables:
$T0 as Int @ locator@0x7faa21801000 [[email protected]:2:15]
Overload choices:
locator@0x7faa21801000 [[email protected]:2:15] with test.(file)[email protected]:1:5 as a: Int
Constraint restrictions:
Int to Optional<Int> is [value-to-optional]
Disjunction choices:
---Type-checked expression---
(declref_expr type='Int' location=test.swift:2:15 range=[test.swift:2:15 - line:2:15] decl=test.(file)[email protected]:1:5 direct_to_storage function_ref=unapplied)
let a: Int = 0
let b: Int? = a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment