Throw if set! passed incorrect number of arguments

Description

In the following, the first and last should throw:

Implementation guidance:

The message thrown should be derived from Clojure, perhaps "Malformed assignment, expecting (set! target val) or (set! target -prop val)"

The check and throw can be added to the analyzer's code which parses 'set!:
https://github.com/clojure/clojurescript/blob/6eedd0a08c49f7b0d4dcb30977b2fb38c90577bd/src/main/clojure/cljs/analyzer.cljc#L2229

An example of a similar throw is in the analyzer code for 'if:
https://github.com/clojure/clojurescript/blob/6eedd0a08c49f7b0d4dcb30977b2fb38c90577bd/src/main/clojure/cljs/analyzer.cljc#L1446-L1449

Tests can be added in cljs.analyzer-tests (which is run via lein test): https://github.com/clojure/clojurescript/blob/master/src/test/clojure/cljs/analyzer_tests.clj

Environment

None

Activity

Show:
Robin Schroer
October 3, 2018, 3:05 PM

I just have, yes.

Mike Fikes
October 3, 2018, 4:57 PM

CLJS-2923.patch LGTM. It behaves properly, and passes in CI and Canary tests.

Mike Fikes
May 30, 2020, 1:06 PM
Edited

CLJS-2923-2.patch rebaselines Robin's patch.

Travis

Details

AppVeyor

Details

Mike Fikes
May 30, 2020, 1:14 PM

Hey Robin, I made a revised patch of yours and it is failing against master. I suspect this could be due to something else outside of your patch. Would you mind taking a look to see if may have done anything obviously wrong when updating the patch? - Mike

Robin Schroer
August 28, 2020, 2:21 PM

Hi Mike, sorry for the long wait, I was fighting Jira to let me login again.

I’ve got -3.patch that passes tests locally for me.

 

Assignee

Robin Schroer

Reporter

Mike Fikes

Labels

Approval

Accepted

Patch

Code and Test

Priority

Major
Configure