From 241d97c53874f043ea0a176f82b8f456cd7b4c5b Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Fri, 9 Feb 2024 11:47:41 -0500
Subject: [PATCH 1/4] Use str instead of name to stringify symbols

---
 src/main/com/yetanalytics/flint/axiom/impl.cljc            | 4 ++--
 src/main/com/yetanalytics/flint/axiom/impl/format.cljc     | 4 ++--
 src/main/com/yetanalytics/flint/axiom/impl/validation.cljc | 5 ++---
 src/main/com/yetanalytics/flint/error.cljc                 | 6 +++---
 src/main/com/yetanalytics/flint/format/expr.cljc           | 2 +-
 src/main/com/yetanalytics/flint/format/modifier.cljc       | 2 +-
 6 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/main/com/yetanalytics/flint/axiom/impl.cljc b/src/main/com/yetanalytics/flint/axiom/impl.cljc
index cfe2318..1d40960 100644
--- a/src/main/com/yetanalytics/flint/axiom/impl.cljc
+++ b/src/main/com/yetanalytics/flint/axiom/impl.cljc
@@ -168,7 +168,7 @@
 
   #?(:clj clojure.lang.Symbol :cljs Symbol)
   (-valid-wildcard? [sym] (= '* sym))
-  (-format-wildcard [sym] (name sym)))
+  (-format-wildcard [sym] (str sym)))
 
 (extend-protocol p/RDFType
   #?(:clj clojure.lang.Keyword :cljs Keyword)
@@ -177,7 +177,7 @@
 
   #?(:clj clojure.lang.Symbol :cljs Symbol)
   (-valid-rdf-type? [sym] (= 'a sym))
-  (-format-rdf-type [sym] (name sym)))
+  (-format-rdf-type [sym] (str sym)))
 
 ;; Defaults
 
diff --git a/src/main/com/yetanalytics/flint/axiom/impl/format.cljc b/src/main/com/yetanalytics/flint/axiom/impl/format.cljc
index 66b87eb..4c9b847 100644
--- a/src/main/com/yetanalytics/flint/axiom/impl/format.cljc
+++ b/src/main/com/yetanalytics/flint/axiom/impl/format.cljc
@@ -25,14 +25,14 @@
 (defn format-var-symbol
   "Return the var `v-sym` as a string of the form `?var`."
   [v-sym]
-  (name v-sym))
+  (str v-sym))
 
 (defn format-bnode-symbol
   "Return the bnode `b-sym` as a string of the form `_:bnode`. Returns
    `[]` if `b-sym` is a single underscore."
   [b-sym]
   (if (not= '_ b-sym)
-    (let [^String s  (name b-sym)
+    (let [^String s  (str b-sym)
           sub-string (.substring s 1 (count s))]
       (str "_:" sub-string))
     "[]"))
diff --git a/src/main/com/yetanalytics/flint/axiom/impl/validation.cljc b/src/main/com/yetanalytics/flint/axiom/impl/validation.cljc
index 190aa22..bdfb195 100644
--- a/src/main/com/yetanalytics/flint/axiom/impl/validation.cljc
+++ b/src/main/com/yetanalytics/flint/axiom/impl/validation.cljc
@@ -580,13 +580,13 @@
 (defn valid-var-symbol?
   "Is `var-sym` a symbol that starts with `?`?"
   [var-sym]
-  (valid-var-str? (name var-sym)))
+  (valid-var-str? (str var-sym)))
 
 (defn valid-bnode-symbol?
   "Is `bnode-sym` a symbol that starts with `_` and has zero or more
    trailing chars?"
   [bnode-sym]
-  (valid-bnode-str? (name bnode-sym)))
+  (valid-bnode-str? (str bnode-sym)))
 
 ;; Literals
 
@@ -617,4 +617,3 @@
                   (string? lval)
                   (valid-lang-tag-str? (name ltag))
                   (valid-literal-str? lval)))))
-
diff --git a/src/main/com/yetanalytics/flint/error.cljc b/src/main/com/yetanalytics/flint/error.cljc
index 963592e..036f8b7 100644
--- a/src/main/com/yetanalytics/flint/error.cljc
+++ b/src/main/com/yetanalytics/flint/error.cljc
@@ -160,7 +160,7 @@
                      (->> nots (mapcat :variables) distinct sort)
                      (->> ins (map :variable) distinct sort))
         var-count  (->> var-coll count)
-        var-strs   (->> var-coll (map name))
+        var-strs   (->> var-coll (map str))
         var-str    (join-str-coll var-strs)]
     (fmt "%d variable%s%s in %d `expr AS var` clause%s %s %s defined in scope: %s!'"
          var-count
@@ -197,7 +197,7 @@
              (plural-has wild-count)))
       (let [var-coll (->> errs (mapcat :variables) distinct sort)
             var-count (->> var-coll count)
-            var-strs  (->> var-coll (map name))
+            var-strs  (->> var-coll (map str))
             var-str   (join-str-coll var-strs)]
         (fmt "%d variable%s%s %s illegally used in SELECTs with aggregates: %s!"
              var-count
@@ -220,7 +220,7 @@
   [bnode-err-m index-str]
   (let [bnode-coll  (->> bnode-err-m :errors (map :bnode) distinct)
         bnode-count (count bnode-coll)
-        bnode-strs  (->> bnode-coll (map name))
+        bnode-strs  (->> bnode-coll (map str))
         bnode-str   (if (= 1 bnode-count)
                       (first bnode-strs)
                       (fmt "%s and %s"
diff --git a/src/main/com/yetanalytics/flint/format/expr.cljc b/src/main/com/yetanalytics/flint/format/expr.cljc
index 2dcfc2a..0413b02 100644
--- a/src/main/com/yetanalytics/flint/format/expr.cljc
+++ b/src/main/com/yetanalytics/flint/format/expr.cljc
@@ -26,7 +26,7 @@
 
 (defn- op->str
   [op]
-  (let [op-name (name op)]
+  (let [op-name (str op)]
     (case op-name
       "-"      "-" ; Otherwise will be removed below
       "not="   "!="
diff --git a/src/main/com/yetanalytics/flint/format/modifier.cljc b/src/main/com/yetanalytics/flint/format/modifier.cljc
index 8a21e7f..c90bb07 100644
--- a/src/main/com/yetanalytics/flint/format/modifier.cljc
+++ b/src/main/com/yetanalytics/flint/format/modifier.cljc
@@ -3,7 +3,7 @@
             [com.yetanalytics.flint.format :as f]))
 
 (defmethod f/format-ast-node :mod/op [_ [_ op]]
-  (name op))
+  (str op))
 
 (defmethod f/format-ast-node :mod/asc-desc [_ [_ [op sub-expr]]]
   (let [op-name (cstr/upper-case op)]

From ddfd8ac4b0922dafff3b2ebe4a2d03759d73369f Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Fri, 9 Feb 2024 11:47:52 -0500
Subject: [PATCH 2/4] Test that syntax-quoting symbols is banned

---
 src/test/com/yetanalytics/flint/spec/axiom_test.cljc |  7 +++++--
 src/test/com/yetanalytics/flint/spec/expr_test.cljc  |  7 ++++++-
 src/test/com/yetanalytics/flint/spec/path_test.cljc  | 10 +++++++++-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/test/com/yetanalytics/flint/spec/axiom_test.cljc b/src/test/com/yetanalytics/flint/spec/axiom_test.cljc
index 588d2c3..0534fdf 100644
--- a/src/test/com/yetanalytics/flint/spec/axiom_test.cljc
+++ b/src/test/com/yetanalytics/flint/spec/axiom_test.cljc
@@ -240,11 +240,14 @@
   (testing "variables"
     (is (s/valid? ax/variable-spec '?foo))
     (is (not (s/valid? ax/variable-spec "?foo")))
-    (is (not (s/valid? ax/variable-spec 'foo))))
+    (is (not (s/valid? ax/variable-spec 'foo)))
+    (is (not (s/valid? ax/variable-spec `?foo))))
   (testing "blank nodes"
     (is (s/valid? ax/bnode-spec '_))
     (is (s/valid? ax/bnode-spec '_foo))
-    (is (not (s/valid? ax/bnode-spec 'foo))))
+    (is (not (s/valid? ax/bnode-spec 'foo)))
+    (is (not (s/valid? ax/bnode-spec `_)))
+    (is (not (s/valid? ax/bnode-spec `_foo))))
   (testing "string literals"
     (is (s/valid? ax/literal-spec "foo bar"))
     (is (s/valid? ax/literal-spec "\\\"\\n\\r\\t\\\""))
diff --git a/src/test/com/yetanalytics/flint/spec/expr_test.cljc b/src/test/com/yetanalytics/flint/spec/expr_test.cljc
index 649ad60..cdeccbf 100644
--- a/src/test/com/yetanalytics/flint/spec/expr_test.cljc
+++ b/src/test/com/yetanalytics/flint/spec/expr_test.cljc
@@ -184,7 +184,12 @@
                            :in     []}]
             ::s/spec ::es/expr
             ::s/value '(+)}
-           (s/explain-data ::es/expr '(+))))))
+           (s/explain-data ::es/expr '(+)))))
+  (testing "Invalid expressions due to syntax quoting"
+    (is (not (s/valid? ::es/expr `(+ 2 2))))
+    (is (not (s/valid? ::es/expr `(and true true))))
+    (is (not (s/valid? ::es/expr `(if true 1 0))))
+    (is (not (s/valid? ::es/expr `(contains "foo" "foobar"))))))
 
 (deftest conform-expr-as-var-test
   (testing "Conforming expr AS var clauses"
diff --git a/src/test/com/yetanalytics/flint/spec/path_test.cljc b/src/test/com/yetanalytics/flint/spec/path_test.cljc
index ab8fbee..eda96f9 100644
--- a/src/test/com/yetanalytics/flint/spec/path_test.cljc
+++ b/src/test/com/yetanalytics/flint/spec/path_test.cljc
@@ -139,4 +139,12 @@
                            :in     [1]}]
             ::s/spec ::ps/path
             ::s/value '(not (cat :foo/bar :bar/baz))}
-           (s/explain-data ::ps/path '(not (cat :foo/bar :bar/baz)))))))
+           (s/explain-data ::ps/path '(not (cat :foo/bar :bar/baz)))))
+    (testing "Invalid expressions due to syntax quoting"
+      (is (not (s/valid? ::ps/path `(alt :foo/bar :baz/qux))))
+      (is (not (s/valid? ::ps/path `(cat :foo/bar :baz/qux))))
+      (is (not (s/valid? ::ps/path `(inv :foo/bar))))
+      (is (not (s/valid? ::ps/path `(not :foo/bar))))
+      (is (not (s/valid? ::ps/path `(? :foo/bar))))
+      (is (not (s/valid? ::ps/path `(* :foo/bar))))
+      (is (not (s/valid? ::ps/path `(+ :foo/bar)))))))

From acf27bf01be3fe9ed1b2b3100905183f6848818c Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Fri, 9 Feb 2024 11:52:12 -0500
Subject: [PATCH 3/4] Add to changelog

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 72487a5..5cd3a4e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
 - Add support for blank node vector syntactic sugar.
 - Modify the AST tree for triples to support the new features and to remove redundant nodes in the tree.
 - Rework blank node validation to make the implementation simpler (this results in minor changes to the error output).
+- Disallow syntax-quoting for symbols.
 
 ## v0.2.1
 

From 03f60773c499c13639bcbd60c6555bd5b004c8ea Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Fri, 9 Feb 2024 11:54:30 -0500
Subject: [PATCH 4/4] Remove weird test case that only fails in cljs

---
 src/test/com/yetanalytics/flint/spec/expr_test.cljc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/test/com/yetanalytics/flint/spec/expr_test.cljc b/src/test/com/yetanalytics/flint/spec/expr_test.cljc
index cdeccbf..a86d12c 100644
--- a/src/test/com/yetanalytics/flint/spec/expr_test.cljc
+++ b/src/test/com/yetanalytics/flint/spec/expr_test.cljc
@@ -188,7 +188,6 @@
   (testing "Invalid expressions due to syntax quoting"
     (is (not (s/valid? ::es/expr `(+ 2 2))))
     (is (not (s/valid? ::es/expr `(and true true))))
-    (is (not (s/valid? ::es/expr `(if true 1 0))))
     (is (not (s/valid? ::es/expr `(contains "foo" "foobar"))))))
 
 (deftest conform-expr-as-var-test