Closed stylewarning closed 3 months ago
CC @amorphedstar
The choice of iterator doesn't seem to matter much.
Simpler repro:
(coalton-codegen
(define (f)
(for x in iter:empty
Unit)))
Last example, node before running inliner:
#S(COALTON-IMPL/CODEGEN/AST:NODE-ABSTRACTION
:TYPE (#T121085 → UNIT)
:VARS (|_51387|)
:SUBEXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-BIND
:TYPE UNIT
:NAME #:ITER-3607
:EXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-APPLICATION
:TYPE (OPTIONAL #T121090)
:RATOR #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE ((ITERATOR #T121090) → (OPTIONAL #T121090))
:VALUE ITER::|INSTANCE/INTOITERATOR (ITERATOR :A) :A-COALTON-LIBRARY/ITERATOR:INTO-ITER|)
:RANDS (#S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE (ITERATOR #T121090)
:VALUE ITER:EMPTY)))
:BODY #S(COALTON-IMPL/CODEGEN/AST:NODE-WHILE-LET
:TYPE UNIT
:LABEL :COALTON-LOOP
:PATTERN #S(COALTON-IMPL/CODEGEN/PATTERN:PATTERN-CONSTRUCTOR
:TYPE (OPTIONAL #T121090)
:NAME SOME
:PATTERNS (#S(COALTON-IMPL/CODEGEN/PATTERN:PATTERN-VAR
:TYPE #T121090
:NAME X-51386)))
:EXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-APPLICATION
:TYPE (OPTIONAL #T121090)
:RATOR #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE ((ITERATOR (ITERATOR #T121090)) → (OPTIONAL #T121090))
:VALUE ITER:NEXT!)
:RANDS (#S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE (ITERATOR (ITERATOR #T121090))
:VALUE #:ITER-3607)))
:BODY #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE UNIT
:VALUE UNIT))))
after, fails type checking:
#S(COALTON-IMPL/CODEGEN/AST:NODE-ABSTRACTION
:TYPE (#T121085 → UNIT)
:VARS (|_51387|)
:SUBEXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-BIND
:TYPE UNIT
:NAME #:ITER-3607
:EXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-LET
:TYPE (OPTIONAL #T121090)
:BINDINGS ((X-4450051388
. #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE (ITERATOR #T121090)
:VALUE ITER:EMPTY)))
:SUBEXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-LET
:TYPE (ITERATOR #T121137)
:BINDINGS ((X-3966751389
. #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE (ITERATOR #T121136)
:VALUE X-4450051388)))
:SUBEXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE (ITERATOR #T121138)
:VALUE X-3966751389)))
:BODY #S(COALTON-IMPL/CODEGEN/AST:NODE-WHILE-LET
:TYPE UNIT
:LABEL :COALTON-LOOP
:PATTERN #S(COALTON-IMPL/CODEGEN/PATTERN:PATTERN-CONSTRUCTOR
:TYPE (OPTIONAL #T121090)
:NAME SOME
:PATTERNS (#S(COALTON-IMPL/CODEGEN/PATTERN:PATTERN-VAR
:TYPE #T121090
:NAME X-51386)))
:EXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-LET
:TYPE (OPTIONAL #T121090)
:BINDINGS ((ITER-4414851390
. #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE (ITERATOR (ITERATOR #T121090))
:VALUE #:ITER-3607)))
:SUBEXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-MATCH
:TYPE (OPTIONAL #T121140)
:EXPR #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE (ITERATOR (ITERATOR #T121139))
:VALUE ITER-4414851390)
:BRANCHES (#S(COALTON-IMPL/CODEGEN/AST:MATCH-BRANCH
:PATTERN #S(COALTON-IMPL/CODEGEN/PATTERN:PATTERN-CONSTRUCTOR
:TYPE (ITERATOR #T121140)
:NAME ITER::%ITERATOR
:PATTERNS (#S(COALTON-IMPL/CODEGEN/PATTERN:PATTERN-VAR
:TYPE (UNIT → (OPTIONAL #T121140))
:NAME ITER::FUNC-44149)
#S(COALTON-IMPL/CODEGEN/PATTERN:PATTERN-WILDCARD
:TYPE (OPTIONAL UFIX))))
:BODY #S(COALTON-IMPL/CODEGEN/AST:NODE-APPLICATION
:TYPE (OPTIONAL #T121140)
:RATOR #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE (UNIT → (OPTIONAL #T121140))
:VALUE ITER::FUNC-44149)
:RANDS (#S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE UNIT
:VALUE UNIT)))))))
:BODY #S(COALTON-IMPL/CODEGEN/AST:NODE-VARIABLE
:TYPE UNIT
:VALUE UNIT)))
I think the inliner is a red herring. Something is wrong with the while-let
translation. I think it's buggy.
EDIT:
I thought this was a bug in the inliner, but it appears that the
translate-expression
method ofnode-for
is doing manual type constructions, and those type constructions are incorrect.Original post:
repro:
Enable inlining, and
results in