daphne-project / daphne-project/daphne

Solve problems of sharing + for addition and string concat

Open
#449 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
81
Forks
83
PR merge metrics
No merged PRs in 30d

Description

DaphneDSL uses operator `+` for both (elementwise) addition and (elementwise) string concatenation. However, at parse-time we cannot safely know which of the two operations we need to create, because argument types might still be unknown in some situations. Our initial attempt was to create a `EwAddOp` during parsing and to rewrite it during canonicalization if arguments turn out to be strings. Nevertheless, this causes problems, since addition is commutative and string concat ist not: the compiler might have swapped operands by then, leading to wrong string concat results.

As a quick fix, we remove the `Commutative` trait from `EwAddOp`. However, we need a clean solution.

Contributor guide

Open the contributing guide

Research direction

Begin with EwAddOp and its Commutative trait, then trace its parse-time creation and canonicalization rewrite. Done means a clean representation or rewrite strategy distinguishes elementwise addition from string concatenation without allowing operand reordering to change concatenation results.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.